2 This file is part of GNUnet.
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details.
16 * @file peerstore/perf_peerstore_store.c
17 * @brief performance test for peerstore store operation
20 #include "gnunet_util_lib.h"
21 #include "gnunet_testing_lib.h"
22 #include "gnunet_peerstore_service.h"
28 static struct GNUNET_PEERSTORE_Handle *h;
30 static char *ss = "test_peerstore_stress";
31 static struct GNUNET_PeerIdentity p;
32 static char *k = "test_peerstore_stress_key";
33 static char *v = "test_peerstore_stress_val";
41 GNUNET_PEERSTORE_disconnect (h, GNUNET_YES);
42 GNUNET_SCHEDULER_shutdown ();
49 GNUNET_PEERSTORE_store (h, ss, &p, k, v, strlen (v) + 1,
50 GNUNET_TIME_UNIT_FOREVER_ABS,
52 0) ? GNUNET_PEERSTORE_STOREOPTION_REPLACE :
53 GNUNET_PEERSTORE_STOREOPTION_MULTIPLE, NULL, NULL);
59 watch_cb (void *cls, const struct GNUNET_PEERSTORE_Record *record,
62 GNUNET_assert (NULL == emsg);
74 run (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg,
75 struct GNUNET_TESTING_Peer *peer)
77 memset (&p, 5, sizeof (p));
78 h = GNUNET_PEERSTORE_connect (cfg);
79 GNUNET_assert (NULL != h);
80 GNUNET_PEERSTORE_watch (h, ss, &p, k, &watch_cb, NULL);
86 main (int argc, char *argv[])
88 struct GNUNET_TIME_Absolute start;
89 struct GNUNET_TIME_Relative diff;
91 start = GNUNET_TIME_absolute_get ();
93 GNUNET_TESTING_service_run ("perf-peerstore-store", "peerstore",
94 "test_peerstore_api_data.conf", &run, NULL))
96 diff = GNUNET_TIME_absolute_get_duration (start);
97 fprintf (stderr, "Stored and retrieved %d records in %s (%s).\n", STORES,
98 GNUNET_STRINGS_relative_time_to_string (diff, GNUNET_YES),
99 GNUNET_STRINGS_relative_time_to_string (diff, GNUNET_NO));
103 /* end of perf_peerstore_store.c */