aboutsummaryrefslogtreecommitdiff
path: root/src/datastore/perf_plugin_datastore.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_plugin_datastore.c
parent6fd3e715cae09fa6e657c96f1c6f9711ee51f42f (diff)
downloadgnunet-5746309cb4be2073d550ad7a6885e918631dbc38.tar.gz
gnunet-5746309cb4be2073d550ad7a6885e918631dbc38.zip
indentation
Diffstat (limited to 'src/datastore/perf_plugin_datastore.c')
-rw-r--r--src/datastore/perf_plugin_datastore.c89
1 files changed, 34 insertions, 55 deletions
diff --git a/src/datastore/perf_plugin_datastore.c b/src/datastore/perf_plugin_datastore.c
index f8a3705e4..1e2a29f14 100644
--- a/src/datastore/perf_plugin_datastore.c
+++ b/src/datastore/perf_plugin_datastore.c
@@ -149,14 +149,10 @@ static void test (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc);
149 149
150 150
151static int 151static int
152iterate_zeros (void *cls, 152iterate_zeros (void *cls, const GNUNET_HashCode * key, uint32_t size,
153 const GNUNET_HashCode * key, 153 const void *data, enum GNUNET_BLOCK_Type type, uint32_t priority,
154 uint32_t size, 154 uint32_t anonymity, struct GNUNET_TIME_Absolute expiration,
155 const void *data, 155 uint64_t uid)
156 enum GNUNET_BLOCK_Type type,
157 uint32_t priority,
158 uint32_t anonymity,
159 struct GNUNET_TIME_Absolute expiration, uint64_t uid)
160{ 156{
161 struct CpsRunContext *crc = cls; 157 struct CpsRunContext *crc = cls;
162 int i; 158 int i;
@@ -187,8 +183,7 @@ iterate_zeros (void *cls,
187 (unsigned long long) (crc->end.abs_value - crc->start.abs_value), 183 (unsigned long long) (crc->end.abs_value - crc->start.abs_value),
188 bc, crc->cnt); 184 bc, crc->cnt);
189 if (crc->cnt > 0) 185 if (crc->cnt > 0)
190 GAUGER (category, 186 GAUGER (category, "Select random zero-anonymity item",
191 "Select random zero-anonymity item",
192 (crc->end.abs_value - crc->start.abs_value) / crc->cnt, 187 (crc->end.abs_value - crc->start.abs_value) / crc->cnt,
193 "ms/item"); 188 "ms/item");
194 memset (hits, 0, sizeof (hits)); 189 memset (hits, 0, sizeof (hits));
@@ -202,13 +197,9 @@ iterate_zeros (void *cls,
202 197
203 198
204static int 199static int
205expiration_get (void *cls, 200expiration_get (void *cls, const GNUNET_HashCode * key, uint32_t size,
206 const GNUNET_HashCode * key, 201 const void *data, enum GNUNET_BLOCK_Type type,
207 uint32_t size, 202 uint32_t priority, uint32_t anonymity,
208 const void *data,
209 enum GNUNET_BLOCK_Type type,
210 uint32_t priority,
211 uint32_t anonymity,
212 struct GNUNET_TIME_Absolute expiration, uint64_t uid) 203 struct GNUNET_TIME_Absolute expiration, uint64_t uid)
213{ 204{
214 struct CpsRunContext *crc = cls; 205 struct CpsRunContext *crc = cls;
@@ -234,8 +225,7 @@ expiration_get (void *cls,
234 (unsigned long long) (crc->end.abs_value - crc->start.abs_value), 225 (unsigned long long) (crc->end.abs_value - crc->start.abs_value),
235 bc, (unsigned int) PUT_10); 226 bc, (unsigned int) PUT_10);
236 if (crc->cnt > 0) 227 if (crc->cnt > 0)
237 GAUGER (category, 228 GAUGER (category, "Selecting and deleting by expiration",
238 "Selecting and deleting by expiration",
239 (crc->end.abs_value - crc->start.abs_value) / crc->cnt, 229 (crc->end.abs_value - crc->start.abs_value) / crc->cnt,
240 "ms/item"); 230 "ms/item");
241 memset (hits, 0, sizeof (hits)); 231 memset (hits, 0, sizeof (hits));
@@ -252,13 +242,9 @@ expiration_get (void *cls,
252 242
253 243
254static int 244static int
255replication_get (void *cls, 245replication_get (void *cls, const GNUNET_HashCode * key, uint32_t size,
256 const GNUNET_HashCode * key, 246 const void *data, enum GNUNET_BLOCK_Type type,
257 uint32_t size, 247 uint32_t priority, uint32_t anonymity,
258 const void *data,
259 enum GNUNET_BLOCK_Type type,
260 uint32_t priority,
261 uint32_t anonymity,
262 struct GNUNET_TIME_Absolute expiration, uint64_t uid) 248 struct GNUNET_TIME_Absolute expiration, uint64_t uid)
263{ 249{
264 struct CpsRunContext *crc = cls; 250 struct CpsRunContext *crc = cls;
@@ -285,8 +271,7 @@ replication_get (void *cls,
285 (unsigned long long) (crc->end.abs_value - crc->start.abs_value), 271 (unsigned long long) (crc->end.abs_value - crc->start.abs_value),
286 bc, (unsigned int) PUT_10); 272 bc, (unsigned int) PUT_10);
287 if (crc->cnt > 0) 273 if (crc->cnt > 0)
288 GAUGER (category, 274 GAUGER (category, "Selecting random item for replication",
289 "Selecting random item for replication",
290 (crc->end.abs_value - crc->start.abs_value) / crc->cnt, 275 (crc->end.abs_value - crc->start.abs_value) / crc->cnt,
291 "ms/item"); 276 "ms/item");
292 memset (hits, 0, sizeof (hits)); 277 memset (hits, 0, sizeof (hits));
@@ -316,12 +301,12 @@ unload_plugin (struct GNUNET_DATASTORE_PluginFunctions *api,
316 char *libname; 301 char *libname;
317 302
318 if (GNUNET_OK != 303 if (GNUNET_OK !=
319 GNUNET_CONFIGURATION_get_value_string (cfg, 304 GNUNET_CONFIGURATION_get_value_string (cfg, "DATASTORE", "DATABASE",
320 "DATASTORE", "DATABASE", &name)) 305 &name))
321 { 306 {
322 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 307 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
323 _("No `%s' specified for `%s' in configuration!\n"), 308 _("No `%s' specified for `%s' in configuration!\n"), "DATABASE",
324 "DATABASE", "DATASTORE"); 309 "DATASTORE");
325 return; 310 return;
326 } 311 }
327 GNUNET_asprintf (&libname, "libgnunet_plugin_datastore_%s", name); 312 GNUNET_asprintf (&libname, "libgnunet_plugin_datastore_%s", name);
@@ -375,13 +360,11 @@ test (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
375 putValue (crc->api, j, crc->i); 360 putValue (crc->api, j, crc->i);
376 crc->end = GNUNET_TIME_absolute_get (); 361 crc->end = GNUNET_TIME_absolute_get ();
377 { 362 {
378 printf ("%s took %llu ms for %llu items\n", 363 printf ("%s took %llu ms for %llu items\n", "Storing an item",
379 "Storing an item",
380 (unsigned long long) (crc->end.abs_value - crc->start.abs_value), 364 (unsigned long long) (crc->end.abs_value - crc->start.abs_value),
381 PUT_10); 365 PUT_10);
382 if (PUT_10 > 0) 366 if (PUT_10 > 0)
383 GAUGER (category, 367 GAUGER (category, "Storing an item",
384 "Storing an item",
385 (crc->end.abs_value - crc->start.abs_value) / PUT_10, 368 (crc->end.abs_value - crc->start.abs_value) / PUT_10,
386 "ms/item"); 369 "ms/item");
387 } 370 }
@@ -394,8 +377,8 @@ test (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
394 crc->api->get_replication (crc->api->cls, &replication_get, crc); 377 crc->api->get_replication (crc->api->cls, &replication_get, crc);
395 break; 378 break;
396 case RP_ZA_GET: 379 case RP_ZA_GET:
397 crc->api->get_zero_anonymity (crc->api->cls, 380 crc->api->get_zero_anonymity (crc->api->cls, crc->offset++, 1,
398 crc->offset++, 1, &iterate_zeros, crc); 381 &iterate_zeros, crc);
399 break; 382 break;
400 case RP_EXP_GET: 383 case RP_EXP_GET:
401 crc->api->get_expiration (crc->api->cls, &expiration_get, crc); 384 crc->api->get_expiration (crc->api->cls, &expiration_get, crc);
@@ -422,19 +405,19 @@ load_plugin (const struct GNUNET_CONFIGURATION_Handle *cfg)
422 char *libname; 405 char *libname;
423 406
424 if (GNUNET_OK != 407 if (GNUNET_OK !=
425 GNUNET_CONFIGURATION_get_value_string (cfg, 408 GNUNET_CONFIGURATION_get_value_string (cfg, "DATASTORE", "DATABASE",
426 "DATASTORE", "DATABASE", &name)) 409 &name))
427 { 410 {
428 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 411 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
429 _("No `%s' specified for `%s' in configuration!\n"), 412 _("No `%s' specified for `%s' in configuration!\n"), "DATABASE",
430 "DATABASE", "DATASTORE"); 413 "DATASTORE");
431 return NULL; 414 return NULL;
432 } 415 }
433 env.cfg = cfg; 416 env.cfg = cfg;
434 env.duc = &disk_utilization_change_cb; 417 env.duc = &disk_utilization_change_cb;
435 env.cls = NULL; 418 env.cls = NULL;
436 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 419 GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Loading `%s' datastore plugin\n"),
437 _("Loading `%s' datastore plugin\n"), name); 420 name);
438 GNUNET_asprintf (&libname, "libgnunet_plugin_datastore_%s", name); 421 GNUNET_asprintf (&libname, "libgnunet_plugin_datastore_%s", name);
439 if (NULL == (ret = GNUNET_PLUGIN_load (libname, &env))) 422 if (NULL == (ret = GNUNET_PLUGIN_load (libname, &env)))
440 { 423 {
@@ -448,9 +431,8 @@ load_plugin (const struct GNUNET_CONFIGURATION_Handle *cfg)
448 431
449 432
450static void 433static void
451run (void *cls, 434run (void *cls, char *const *args, const char *cfgfile,
452 char *const *args, 435 const struct GNUNET_CONFIGURATION_Handle *c)
453 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c)
454{ 436{
455 struct GNUNET_DATASTORE_PluginFunctions *api; 437 struct GNUNET_DATASTORE_PluginFunctions *api;
456 struct CpsRunContext *crc; 438 struct CpsRunContext *crc;
@@ -490,12 +472,10 @@ check ()
490 }; 472 };
491 473
492 GNUNET_snprintf (category, sizeof (category), "DATASTORE-%s", plugin_name); 474 GNUNET_snprintf (category, sizeof (category), "DATASTORE-%s", plugin_name);
493 GNUNET_snprintf (cfg_name, 475 GNUNET_snprintf (cfg_name, sizeof (cfg_name),
494 sizeof (cfg_name),
495 "perf_plugin_datastore_data_%s.conf", plugin_name); 476 "perf_plugin_datastore_data_%s.conf", plugin_name);
496 GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, 477 GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv,
497 argv, "perf-plugin-datastore", "nohelp", 478 "perf-plugin-datastore", "nohelp", options, &run, NULL);
498 options, &run, NULL);
499 if (ok != 0) 479 if (ok != 0)
500 fprintf (stderr, "Missed some testcases: %u\n", ok); 480 fprintf (stderr, "Missed some testcases: %u\n", ok);
501 return ok; 481 return ok;
@@ -519,9 +499,8 @@ main (int argc, char *argv[])
519 else 499 else
520 pos = (char *) plugin_name; 500 pos = (char *) plugin_name;
521 501
522 GNUNET_snprintf (dir_name, 502 GNUNET_snprintf (dir_name, sizeof (dir_name), "/tmp/perf-gnunet-datastore-%s",
523 sizeof (dir_name), 503 plugin_name);
524 "/tmp/perf-gnunet-datastore-%s", plugin_name);
525 GNUNET_DISK_directory_remove (dir_name); 504 GNUNET_DISK_directory_remove (dir_name);
526 GNUNET_log_setup ("perf-plugin-datastore", 505 GNUNET_log_setup ("perf-plugin-datastore",
527#if VERBOSE 506#if VERBOSE