- /* insert data equivalent to 1/10th of MAX_SIZE */
- for (j = 0; j < PUT_10; j++)
- GNUNET_assert (GNUNET_OK == putValue (j, i));
-
- /* trim down below MAX_SIZE again */
- if ((i % 2) == 0)
- GNUNET_DATASTORE_get_random (datastore, &iterate_delete, NULL);
- size = 0;
- printf (
-#if REPORT_ID
- "\n"
-#endif
- "Stored %llu kB / %lluk ops / %llu ops/s\n",
- stored_bytes / 1024, /* used size in k */
- (stored_ops * 2 - stored_entries) / 1024, /* total operations (in k) */
- 1000 * (stored_ops * 2 - stored_entries) / (1 + GNUNET_TIME_absolute_get_duration(start_time).value)); /* operations per second */
- }
- GNUNET_DATASTORE_disconnect (datastore, GNUNET_YES);
+ "Stored %llu kB / %lluk ops / %llu ops/s\n", stored_bytes / 1024, /* used size in k */
+ stored_ops / 1024, /* total operations (in k) */
+ 1000 * stored_ops / (1 +
+ GNUNET_TIME_absolute_get_duration
+ (start_time).rel_value));
+ crc->phase = RP_PUT;
+ crc->j = 0;
+ GNUNET_SCHEDULER_add_continuation (&run_continuation, crc,
+ GNUNET_SCHEDULER_REASON_PREREQ_DONE);
+ break;
+ case RP_DONE:
+ GNUNET_snprintf (gstr, sizeof (gstr), "DATASTORE-%s", plugin_name);
+ if ((crc->i == ITERATIONS) && (stored_ops > 0))
+ GAUGER (gstr, "PUT operation duration",
+ GNUNET_TIME_absolute_get_duration (start_time).rel_value /
+ stored_ops, "ms/operation");
+ GNUNET_DATASTORE_disconnect (datastore, GNUNET_YES);
+ GNUNET_free (crc);
+ ok = 0;
+ break;
+ case RP_ERROR:
+ GNUNET_DATASTORE_disconnect (datastore, GNUNET_YES);
+ GNUNET_free (crc);
+ ok = 1;
+ break;
+ default:
+ GNUNET_assert (0);
+ }
+}
+
+
+static void
+run_tests (void *cls, int success, const char *msg)
+{
+ struct CpsRunContext *crc = cls;
+
+ if (success != GNUNET_YES)
+ {
+ fprintf (stderr,
+ "Test 'put' operation failed with error `%s' database likely not setup, skipping test.",
+ msg);
+ GNUNET_free (crc);
+ return;
+ }
+ GNUNET_SCHEDULER_add_continuation (&run_continuation, crc,
+ GNUNET_SCHEDULER_REASON_PREREQ_DONE);
+}
+
+
+static void
+run (void *cls, char *const *args, const char *cfgfile,
+ const struct GNUNET_CONFIGURATION_Handle *cfg)
+{
+ struct CpsRunContext *crc;
+ static GNUNET_HashCode zkey;
+
+ datastore = GNUNET_DATASTORE_connect (cfg);
+ start_time = GNUNET_TIME_absolute_get ();
+ crc = GNUNET_malloc (sizeof (struct CpsRunContext));
+ crc->cfg = cfg;
+ crc->phase = RP_PUT;
+ if (NULL ==
+ GNUNET_DATASTORE_put (datastore, 0, &zkey, 4, "TEST",
+ GNUNET_BLOCK_TYPE_TEST, 0, 0, 0,
+ GNUNET_TIME_relative_to_absolute
+ (GNUNET_TIME_UNIT_SECONDS), 0, 1,
+ GNUNET_TIME_UNIT_MINUTES, &run_tests, crc))
+ {
+ fprintf (stderr, "Test 'put' operation failed.\n");
+ ok = 1;
+ GNUNET_free (crc);
+ }