+static int
+expiration_get (void *cls, const struct GNUNET_HashCode * key, uint32_t size,
+ const void *data, enum GNUNET_BLOCK_Type type,
+ uint32_t priority, uint32_t anonymity,
+ struct GNUNET_TIME_Absolute expiration, uint64_t uid)
+{
+ struct CpsRunContext *crc = cls;
+ int i;
+ const char *cdata = data;
+
+ GNUNET_assert (size >= 8);
+ memcpy (&i, &cdata[4], sizeof (i));
+ hits[i / 8] |= (1 << (i % 8));
+ crc->cnt++;
+ if (PUT_10 <= crc->cnt)
+ {
+ unsigned int bc;
+
+ bc = 0;
+ for (i = 0; i < PUT_10; i++)
+ if (0 != (hits[i / 8] & (1 << (i % 8))))
+ bc++;
+
+ crc->end = GNUNET_TIME_absolute_get ();
+ printf ("%s took %s yielding %u/%u items\n",
+ "Selecting and deleting by expiration",
+ GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_difference (crc->start,
+ crc->end),
+ GNUNET_YES),
+ bc, (unsigned int) PUT_10);
+ if (crc->cnt > 0)
+ GAUGER (category, "Selecting and deleting by expiration",
+ (crc->end.abs_value_us - crc->start.abs_value_us) / 1000LL / crc->cnt,
+ "ms/item");
+ memset (hits, 0, sizeof (hits));
+ if (++crc->iter == ITERATIONS)
+ crc->phase++;
+ else
+ crc->phase = RP_PUT;
+ crc->cnt = 0;
+ crc->start = GNUNET_TIME_absolute_get ();
+ }
+ GNUNET_SCHEDULER_add_now (&test, crc);
+ return GNUNET_NO;
+}
+
+
+static int
+replication_get (void *cls, const struct GNUNET_HashCode * key, uint32_t size,
+ const void *data, enum GNUNET_BLOCK_Type type,
+ uint32_t priority, uint32_t anonymity,
+ struct GNUNET_TIME_Absolute expiration, uint64_t uid)
+{
+ struct CpsRunContext *crc = cls;
+ int i;
+ const char *cdata = data;
+
+ GNUNET_assert (NULL != key);
+ GNUNET_assert (size >= 8);
+ memcpy (&i, &cdata[4], sizeof (i));
+ hits[i / 8] |= (1 << (i % 8));
+ crc->cnt++;
+ if (PUT_10 <= crc->cnt)
+ {
+ unsigned int bc;
+
+ bc = 0;
+ for (i = 0; i < PUT_10; i++)
+ if (0 != (hits[i / 8] & (1 << (i % 8))))
+ bc++;
+
+ crc->end = GNUNET_TIME_absolute_get ();
+ printf ("%s took %s yielding %u/%u items\n",
+ "Selecting random item for replication",
+ GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_difference (crc->start,
+ crc->end),
+ GNUNET_YES),
+ bc, (unsigned int) PUT_10);
+ if (crc->cnt > 0)
+ GAUGER (category, "Selecting random item for replication",
+ (crc->end.abs_value_us - crc->start.abs_value_us) / 1000LL / crc->cnt,
+ "ms/item");
+ memset (hits, 0, sizeof (hits));
+ crc->phase++;
+ crc->offset = 0;
+ crc->cnt = 0;
+ crc->start = GNUNET_TIME_absolute_get ();
+ }
+
+ GNUNET_SCHEDULER_add_now (&test, crc);
+ return GNUNET_OK;
+}
+