- "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).value));
- crc->phase = RP_PUT;
- crc->j = 0;
- GNUNET_SCHEDULER_add_continuation (crc->sched,
- &run_continuation,
- crc,
- GNUNET_SCHEDULER_REASON_PREREQ_DONE);
- break;
- case RP_DONE:
- GNUNET_DATASTORE_disconnect (datastore, GNUNET_YES);
- GNUNET_free (crc);
- ok = 0;
- break;
- default:
- GNUNET_assert (0);
+ "Stored %llu kB / %lluk ops / %llu ops/s\n",
+ stored_bytes / 1024, /* used size in k */
+ stored_ops / 1024, /* total operations (in k) */
+ 1000LL * 1000LL * stored_ops / (1 +
+ GNUNET_TIME_absolute_get_duration
+ (start_time).rel_value_us));
+ crc->phase = RP_PUT;
+ crc->j = 0;
+ GNUNET_SCHEDULER_add_now (&run_continuation,
+ crc);
+ break;
+ case RP_PUT_QUOTA:
+ memset (&key,
+ 256 - crc->i,
+ sizeof (struct GNUNET_HashCode));
+ /* most content is 32k */
+ size = 32 * 1024;
+ if (0 ==
+ GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK,
+ 16)) /* but some of it is less! */
+ size = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK,
+ 32 * 1024);
+ crc->size = size = size - (size & 7); /* always multiple of 8 */
+ GNUNET_CRYPTO_hash (&key,
+ sizeof (struct GNUNET_HashCode),
+ &key);
+ memset (data,
+ (int) crc->j,
+ size);
+ if (crc->j > 255)
+ memset (data,
+ (int) (crc->j - 255),
+ size / 2);
+ data[0] = crc->i;
+ GNUNET_assert (NULL !=
+ GNUNET_DATASTORE_put (datastore,
+ 0, /* reservation ID */
+ &key,
+ size,
+ data,
+ crc->j + 1, /* type */
+ GNUNET_CRYPTO_random_u32
+ (GNUNET_CRYPTO_QUALITY_WEAK,
+ 100), /* priority */
+ crc->j, /* anonymity */
+ 0, /* replication */
+ GNUNET_TIME_relative_to_absolute
+ (GNUNET_TIME_relative_multiply
+ (GNUNET_TIME_UNIT_SECONDS,
+ GNUNET_CRYPTO_random_u32
+ (GNUNET_CRYPTO_QUALITY_WEAK, 1000))),
+ 1,
+ 1,
+ TIMEOUT,
+ &check_success, crc));
+ 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_us / 1000LL /
+ stored_ops,
+ "ms/operation");
+ fprintf (stdout,
+ "\nPUT performance: %s for %llu operations\n",
+ GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_duration (start_time),
+ GNUNET_YES),
+ stored_ops);
+ fprintf (stdout,
+ "PUT performance: %llu ms/operation\n",
+ GNUNET_TIME_absolute_get_duration (start_time).rel_value_us / 1000LL /
+ stored_ops);