aboutsummaryrefslogtreecommitdiff
path: root/src/gnsrecord/perf_gnsrecord_crypto.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gnsrecord/perf_gnsrecord_crypto.c')
-rw-r--r--src/gnsrecord/perf_gnsrecord_crypto.c96
1 files changed, 49 insertions, 47 deletions
diff --git a/src/gnsrecord/perf_gnsrecord_crypto.c b/src/gnsrecord/perf_gnsrecord_crypto.c
index a4fffd238..4dadbe9b6 100644
--- a/src/gnsrecord/perf_gnsrecord_crypto.c
+++ b/src/gnsrecord/perf_gnsrecord_crypto.c
@@ -43,77 +43,79 @@
43 43
44 44
45static struct GNUNET_GNSRECORD_Data * 45static struct GNUNET_GNSRECORD_Data *
46create_record(int count) 46create_record (int count)
47{ 47{
48 struct GNUNET_GNSRECORD_Data *rd; 48 struct GNUNET_GNSRECORD_Data *rd;
49 49
50 rd = GNUNET_new_array(count, 50 rd = GNUNET_new_array (count,
51 struct GNUNET_GNSRECORD_Data); 51 struct GNUNET_GNSRECORD_Data);
52 for (unsigned int c = 0; c < count; c++) 52 for (unsigned int c = 0; c < count; c++)
53 { 53 {
54 rd[c].expiration_time = GNUNET_TIME_absolute_get().abs_value_us + 1000000000; 54 rd[c].expiration_time = GNUNET_TIME_absolute_get ().abs_value_us
55 rd[c].record_type = TEST_RECORD_TYPE; 55 + 1000000000;
56 rd[c].data_size = TEST_RECORD_DATALEN; 56 rd[c].record_type = TEST_RECORD_TYPE;
57 rd[c].data = GNUNET_malloc(TEST_RECORD_DATALEN); 57 rd[c].data_size = TEST_RECORD_DATALEN;
58 memset((char *)rd[c].data, TEST_RECORD_DATA, TEST_RECORD_DATALEN); 58 rd[c].data = GNUNET_malloc (TEST_RECORD_DATALEN);
59 } 59 memset ((char *) rd[c].data, TEST_RECORD_DATA, TEST_RECORD_DATALEN);
60 }
60 return rd; 61 return rd;
61} 62}
62 63
63 64
64static void 65static void
65run(void *cls, 66run (void *cls,
66 char *const *args, 67 char *const *args,
67 const char *cfgfile, 68 const char *cfgfile,
68 const struct GNUNET_CONFIGURATION_Handle *cfg) 69 const struct GNUNET_CONFIGURATION_Handle *cfg)
69{ 70{
70 struct GNUNET_GNSRECORD_Block *block; 71 struct GNUNET_GNSRECORD_Block *block;
71 struct GNUNET_HashCode query; 72 struct GNUNET_HashCode query;
72 struct GNUNET_GNSRECORD_Data *s_rd; 73 struct GNUNET_GNSRECORD_Data *s_rd;
73 const char *s_name; 74 const char *s_name;
74 struct GNUNET_TIME_Absolute start_time; 75 struct GNUNET_TIME_Absolute start_time;
75 struct GNUNET_CRYPTO_EcdsaPrivateKey * privkey; 76 struct GNUNET_CRYPTO_EcdsaPrivateKey *privkey;
76 struct GNUNET_TIME_Absolute expire; 77 struct GNUNET_TIME_Absolute expire;
77 78
78 (void)cls; 79 (void) cls;
79 (void)args; 80 (void) args;
80 (void)cfgfile; 81 (void) cfgfile;
81 (void)cfg; 82 (void) cfg;
82 expire = GNUNET_TIME_absolute_get(); 83 expire = GNUNET_TIME_absolute_get ();
83 privkey = GNUNET_CRYPTO_ecdsa_key_create(); 84 privkey = GNUNET_CRYPTO_ecdsa_key_create ();
84 GNUNET_assert(NULL != privkey); 85 GNUNET_assert (NULL != privkey);
85 86
86 /* test block creation */ 87 /* test block creation */
87 s_name = "DUMMY.dummy.gnunet"; 88 s_name = "DUMMY.dummy.gnunet";
88 s_rd = create_record(RECORDS); 89 s_rd = create_record (RECORDS);
89 start_time = GNUNET_TIME_absolute_get(); 90 start_time = GNUNET_TIME_absolute_get ();
90 for (unsigned int i = 0; i < ROUNDS; i++) 91 for (unsigned int i = 0; i < ROUNDS; i++)
91 { 92 {
92 GNUNET_assert(NULL != (block = 93 GNUNET_assert (NULL != (block =
93 GNUNET_GNSRECORD_block_create2(privkey, 94 GNUNET_GNSRECORD_block_create2 (privkey,
94 expire, 95 expire,
95 s_name, 96 s_name,
96 s_rd, 97 s_rd,
97 RECORDS))); 98 RECORDS)));
98 GNUNET_GNSRECORD_query_from_private_key(privkey, 99 GNUNET_GNSRECORD_query_from_private_key (privkey,
99 s_name, 100 s_name,
100 &query); 101 &query);
101 GNUNET_free(block); 102 GNUNET_free (block);
102 } 103 }
103 fprintf(stderr, 104 fprintf (stderr,
104 "Took %s to produce %u GNS blocks for the DHT\n", 105 "Took %s to produce %u GNS blocks for the DHT\n",
105 GNUNET_STRINGS_relative_time_to_string(GNUNET_TIME_absolute_get_duration(start_time), 106 GNUNET_STRINGS_relative_time_to_string (
106 GNUNET_YES), 107 GNUNET_TIME_absolute_get_duration (start_time),
107 ROUNDS); 108 GNUNET_YES),
109 ROUNDS);
108 for (unsigned int i = 0; i < RECORDS; i++) 110 for (unsigned int i = 0; i < RECORDS; i++)
109 GNUNET_free((void *)s_rd[i].data); 111 GNUNET_free ((void *) s_rd[i].data);
110 GNUNET_free(s_rd); 112 GNUNET_free (s_rd);
111 GNUNET_free(privkey); 113 GNUNET_free (privkey);
112} 114}
113 115
114 116
115int 117int
116main(int argc, char *argv[]) 118main (int argc, char *argv[])
117{ 119{
118 static char *const argvx[] = { 120 static char *const argvx[] = {
119 "perf-gnsrecord-crypto", 121 "perf-gnsrecord-crypto",
@@ -124,12 +126,12 @@ main(int argc, char *argv[])
124 }; 126 };
125 127
126 if (GNUNET_OK != 128 if (GNUNET_OK !=
127 GNUNET_PROGRAM_run((sizeof(argvx) / sizeof(char *)) - 1, 129 GNUNET_PROGRAM_run ((sizeof(argvx) / sizeof(char *)) - 1,
128 argvx, 130 argvx,
129 "perf-gnsrecord-crypto", 131 "perf-gnsrecord-crypto",
130 "nohelp", options, 132 "nohelp", options,
131 &run, 133 &run,
132 NULL)) 134 NULL))
133 return 1; 135 return 1;
134 return 0; 136 return 0;
135} 137}