diff options
author | Christian Grothoff <christian@grothoff.org> | 2019-10-05 15:09:28 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2019-10-05 15:09:28 +0200 |
commit | c4e9ba925ffd758aaa3feee2ccfc0b76f26fe207 (patch) | |
tree | cac3ce030d77b4cbe7c7dc62ed58cfe6d24f73e1 /src/nse/perf_kdf.c | |
parent | fbb71d527c7d6babf269a8fefce1db291b9f7068 (diff) | |
download | gnunet-c4e9ba925ffd758aaa3feee2ccfc0b76f26fe207.tar.gz gnunet-c4e9ba925ffd758aaa3feee2ccfc0b76f26fe207.zip |
global reindent, now with uncrustify hook enabled
Diffstat (limited to 'src/nse/perf_kdf.c')
-rw-r--r-- | src/nse/perf_kdf.c | 48 |
1 files changed, 25 insertions, 23 deletions
diff --git a/src/nse/perf_kdf.c b/src/nse/perf_kdf.c index bf4dbe0b2..a6c1432c8 100644 --- a/src/nse/perf_kdf.c +++ b/src/nse/perf_kdf.c | |||
@@ -38,47 +38,49 @@ | |||
38 | * @param result where to write the resulting hash | 38 | * @param result where to write the resulting hash |
39 | */ | 39 | */ |
40 | static void | 40 | static void |
41 | pow_hash(const void *buf, | 41 | pow_hash (const void *buf, |
42 | size_t buf_len, | 42 | size_t buf_len, |
43 | struct GNUNET_HashCode *result) | 43 | struct GNUNET_HashCode *result) |
44 | { | 44 | { |
45 | GNUNET_break(0 == | 45 | GNUNET_break (0 == |
46 | gcry_kdf_derive(buf, buf_len, | 46 | gcry_kdf_derive (buf, buf_len, |
47 | GCRY_KDF_SCRYPT, | 47 | GCRY_KDF_SCRYPT, |
48 | 1 /* subalgo */, | 48 | 1 /* subalgo */, |
49 | "gnunet-proof-of-work", strlen("gnunet-proof-of-work"), | 49 | "gnunet-proof-of-work", strlen ( |
50 | 2 /* iterations; keep cost of individual op small */, | 50 | "gnunet-proof-of-work"), |
51 | sizeof(struct GNUNET_HashCode), result)); | 51 | 2 /* iterations; keep cost of individual op small */, |
52 | sizeof(struct GNUNET_HashCode), result)); | ||
52 | } | 53 | } |
53 | 54 | ||
54 | 55 | ||
55 | static void | 56 | static void |
56 | perfHash() | 57 | perfHash () |
57 | { | 58 | { |
58 | struct GNUNET_HashCode hc; | 59 | struct GNUNET_HashCode hc; |
59 | unsigned int i; | 60 | unsigned int i; |
60 | char buf[64]; | 61 | char buf[64]; |
61 | 62 | ||
62 | memset(buf, 1, sizeof(buf)); | 63 | memset (buf, 1, sizeof(buf)); |
63 | for (i = 0; i < 1024; i++) | 64 | for (i = 0; i < 1024; i++) |
64 | pow_hash(buf, sizeof(buf), &hc); | 65 | pow_hash (buf, sizeof(buf), &hc); |
65 | } | 66 | } |
66 | 67 | ||
67 | 68 | ||
68 | int | 69 | int |
69 | main(int argc, char *argv[]) | 70 | main (int argc, char *argv[]) |
70 | { | 71 | { |
71 | struct GNUNET_TIME_Absolute start; | 72 | struct GNUNET_TIME_Absolute start; |
72 | 73 | ||
73 | start = GNUNET_TIME_absolute_get(); | 74 | start = GNUNET_TIME_absolute_get (); |
74 | perfHash(); | 75 | perfHash (); |
75 | printf("Hash perf took %s\n", | 76 | printf ("Hash perf took %s\n", |
76 | GNUNET_STRINGS_relative_time_to_string(GNUNET_TIME_absolute_get_duration(start), | 77 | GNUNET_STRINGS_relative_time_to_string ( |
77 | GNUNET_YES)); | 78 | GNUNET_TIME_absolute_get_duration (start), |
78 | GAUGER("NSE", "Proof-of-work hashing", | 79 | GNUNET_YES)); |
79 | 1024.0 / (1.0 + | 80 | GAUGER ("NSE", "Proof-of-work hashing", |
80 | GNUNET_TIME_absolute_get_duration | 81 | 1024.0 / (1.0 |
81 | (start).rel_value_us / 1000.0), "hashes/ms"); | 82 | + GNUNET_TIME_absolute_get_duration |
83 | (start).rel_value_us / 1000.0), "hashes/ms"); | ||
82 | return 0; | 84 | return 0; |
83 | } | 85 | } |
84 | 86 | ||