aboutsummaryrefslogtreecommitdiff
path: root/src/datastore/perf_datastore_api.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-08-15 21:54:06 +0000
committerChristian Grothoff <christian@grothoff.org>2011-08-15 21:54:06 +0000
commit5746309cb4be2073d550ad7a6885e918631dbc38 (patch)
tree89455bc4aadf977816b38df13f990372cd81d71a /src/datastore/perf_datastore_api.c
parent6fd3e715cae09fa6e657c96f1c6f9711ee51f42f (diff)
downloadgnunet-5746309cb4be2073d550ad7a6885e918631dbc38.tar.gz
gnunet-5746309cb4be2073d550ad7a6885e918631dbc38.zip
indentation
Diffstat (limited to 'src/datastore/perf_datastore_api.c')
-rw-r--r--src/datastore/perf_datastore_api.c83
1 files changed, 32 insertions, 51 deletions
diff --git a/src/datastore/perf_datastore_api.c b/src/datastore/perf_datastore_api.c
index 9d567aacd..cf9911329 100644
--- a/src/datastore/perf_datastore_api.c
+++ b/src/datastore/perf_datastore_api.c
@@ -104,8 +104,8 @@ struct CpsRunContext
104 104
105 105
106 106
107static void 107static void run_continuation (void *cls,
108run_continuation (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); 108 const struct GNUNET_SCHEDULER_TaskContext *tc);
109 109
110 110
111 111
@@ -138,8 +138,8 @@ check_success (void *cls, int success, const char *msg)
138 else 138 else
139 crc->phase = RP_CUT; 139 crc->phase = RP_CUT;
140 } 140 }
141 GNUNET_SCHEDULER_add_continuation (&run_continuation, 141 GNUNET_SCHEDULER_add_continuation (&run_continuation, crc,
142 crc, GNUNET_SCHEDULER_REASON_PREREQ_DONE); 142 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
143} 143}
144 144
145 145
@@ -172,14 +172,10 @@ remove_next (void *cls, int success, const char *msg)
172 172
173 173
174static void 174static void
175delete_value (void *cls, 175delete_value (void *cls, const GNUNET_HashCode * key, size_t size,
176 const GNUNET_HashCode * key, 176 const void *data, enum GNUNET_BLOCK_Type type, uint32_t priority,
177 size_t size, 177 uint32_t anonymity, struct GNUNET_TIME_Absolute expiration,
178 const void *data, 178 uint64_t uid)
179 enum GNUNET_BLOCK_Type type,
180 uint32_t priority,
181 uint32_t anonymity,
182 struct GNUNET_TIME_Absolute expiration, uint64_t uid)
183{ 179{
184 struct CpsRunContext *crc = cls; 180 struct CpsRunContext *crc = cls;
185 181
@@ -191,11 +187,8 @@ delete_value (void *cls,
191 if (stored_bytes < MAX_SIZE) 187 if (stored_bytes < MAX_SIZE)
192 crc->phase = RP_PUT; 188 crc->phase = RP_PUT;
193 GNUNET_assert (NULL != 189 GNUNET_assert (NULL !=
194 GNUNET_DATASTORE_remove (datastore, 190 GNUNET_DATASTORE_remove (datastore, key, size, data, 1, 1,
195 key, 191 TIMEOUT, &remove_next, crc));
196 size,
197 data,
198 1, 1, TIMEOUT, &remove_next, crc));
199} 192}
200 193
201 194
@@ -228,12 +221,7 @@ run_continuation (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
228 memset (data, i - 255, size / 2); 221 memset (data, i - 255, size / 2);
229 data[0] = k; 222 data[0] = k;
230 GNUNET_assert (NULL != 223 GNUNET_assert (NULL !=
231 GNUNET_DATASTORE_put (datastore, 224 GNUNET_DATASTORE_put (datastore, 0, &key, size, data, i + 1,
232 0,
233 &key,
234 size,
235 data,
236 i + 1,
237 GNUNET_CRYPTO_random_u32 225 GNUNET_CRYPTO_random_u32
238 (GNUNET_CRYPTO_QUALITY_WEAK, 100), i, 226 (GNUNET_CRYPTO_QUALITY_WEAK, 100), i,
239 0, 227 0,
@@ -247,9 +235,9 @@ run_continuation (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
247 case RP_CUT: 235 case RP_CUT:
248 /* trim down below MAX_SIZE again */ 236 /* trim down below MAX_SIZE again */
249 GNUNET_assert (NULL != 237 GNUNET_assert (NULL !=
250 GNUNET_DATASTORE_get_for_replication (datastore, 238 GNUNET_DATASTORE_get_for_replication (datastore, 1, 1,
251 1, 1, TIMEOUT, 239 TIMEOUT, &delete_value,
252 &delete_value, crc)); 240 crc));
253 break; 241 break;
254 case RP_REPORT: 242 case RP_REPORT:
255 printf ( 243 printf (
@@ -263,15 +251,13 @@ run_continuation (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
263 (start_time).rel_value)); 251 (start_time).rel_value));
264 crc->phase = RP_PUT; 252 crc->phase = RP_PUT;
265 crc->j = 0; 253 crc->j = 0;
266 GNUNET_SCHEDULER_add_continuation (&run_continuation, 254 GNUNET_SCHEDULER_add_continuation (&run_continuation, crc,
267 crc,
268 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 255 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
269 break; 256 break;
270 case RP_DONE: 257 case RP_DONE:
271 GNUNET_snprintf (gstr, sizeof (gstr), "DATASTORE-%s", plugin_name); 258 GNUNET_snprintf (gstr, sizeof (gstr), "DATASTORE-%s", plugin_name);
272 if ((crc->i == ITERATIONS) && (stored_ops > 0)) 259 if ((crc->i == ITERATIONS) && (stored_ops > 0))
273 GAUGER (gstr, 260 GAUGER (gstr, "PUT operation duration",
274 "PUT operation duration",
275 GNUNET_TIME_absolute_get_duration (start_time).rel_value / 261 GNUNET_TIME_absolute_get_duration (start_time).rel_value /
276 stored_ops, "ms/operation"); 262 stored_ops, "ms/operation");
277 GNUNET_DATASTORE_disconnect (datastore, GNUNET_YES); 263 GNUNET_DATASTORE_disconnect (datastore, GNUNET_YES);
@@ -302,15 +288,14 @@ run_tests (void *cls, int success, const char *msg)
302 GNUNET_free (crc); 288 GNUNET_free (crc);
303 return; 289 return;
304 } 290 }
305 GNUNET_SCHEDULER_add_continuation (&run_continuation, 291 GNUNET_SCHEDULER_add_continuation (&run_continuation, crc,
306 crc, GNUNET_SCHEDULER_REASON_PREREQ_DONE); 292 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
307} 293}
308 294
309 295
310static void 296static void
311run (void *cls, 297run (void *cls, char *const *args, const char *cfgfile,
312 char *const *args, 298 const struct GNUNET_CONFIGURATION_Handle *cfg)
313 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
314{ 299{
315 struct CpsRunContext *crc; 300 struct CpsRunContext *crc;
316 static GNUNET_HashCode zkey; 301 static GNUNET_HashCode zkey;
@@ -321,10 +306,8 @@ run (void *cls,
321 crc->cfg = cfg; 306 crc->cfg = cfg;
322 crc->phase = RP_PUT; 307 crc->phase = RP_PUT;
323 if (NULL == 308 if (NULL ==
324 GNUNET_DATASTORE_put (datastore, 0, 309 GNUNET_DATASTORE_put (datastore, 0, &zkey, 4, "TEST",
325 &zkey, 4, "TEST", 310 GNUNET_BLOCK_TYPE_TEST, 0, 0, 0,
326 GNUNET_BLOCK_TYPE_TEST,
327 0, 0, 0,
328 GNUNET_TIME_relative_to_absolute 311 GNUNET_TIME_relative_to_absolute
329 (GNUNET_TIME_UNIT_SECONDS), 0, 1, 312 (GNUNET_TIME_UNIT_SECONDS), 0, 1,
330 GNUNET_TIME_UNIT_MINUTES, &run_tests, crc)) 313 GNUNET_TIME_UNIT_MINUTES, &run_tests, crc))
@@ -355,19 +338,18 @@ check ()
355 GNUNET_GETOPT_OPTION_END 338 GNUNET_GETOPT_OPTION_END
356 }; 339 };
357 340
358 GNUNET_snprintf (cfg_name, 341 GNUNET_snprintf (cfg_name, sizeof (cfg_name),
359 sizeof (cfg_name),
360 "test_datastore_api_data_%s.conf", plugin_name); 342 "test_datastore_api_data_%s.conf", plugin_name);
361 proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", 343 proc =
362 "gnunet-service-arm", 344 GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
345 "gnunet-service-arm",
363#if VERBOSE 346#if VERBOSE
364 "-L", "DEBUG", 347 "-L", "DEBUG",
365#endif 348#endif
366 "-c", cfg_name, NULL); 349 "-c", cfg_name, NULL);
367 GNUNET_assert (NULL != proc); 350 GNUNET_assert (NULL != proc);
368 GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, 351 GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv,
369 argv, "perf-datastore-api", "nohelp", 352 "perf-datastore-api", "nohelp", options, &run, NULL);
370 options, &run, NULL);
371 sleep (1); /* give datastore chance to process 'DROP' */ 353 sleep (1); /* give datastore chance to process 'DROP' */
372 if (0 != GNUNET_OS_process_kill (proc, SIGTERM)) 354 if (0 != GNUNET_OS_process_kill (proc, SIGTERM))
373 { 355 {
@@ -398,9 +380,8 @@ main (int argc, char *argv[])
398 else 380 else
399 pos = (char *) plugin_name; 381 pos = (char *) plugin_name;
400 382
401 GNUNET_snprintf (dir_name, 383 GNUNET_snprintf (dir_name, sizeof (dir_name), "/tmp/test-gnunet-datastore-%s",
402 sizeof (dir_name), 384 plugin_name);
403 "/tmp/test-gnunet-datastore-%s", plugin_name);
404 GNUNET_DISK_directory_remove (dir_name); 385 GNUNET_DISK_directory_remove (dir_name);
405 GNUNET_log_setup ("perf-datastore-api", 386 GNUNET_log_setup ("perf-datastore-api",
406#if VERBOSE 387#if VERBOSE