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.
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
19 * @file peerstore/perf_peerstore_store.c
20 * @brief performance test for peerstore store operation
23 #include "gnunet_util_lib.h"
24 #include "gnunet_testing_lib.h"
25 #include "gnunet_peerstore_service.h"
31 static struct GNUNET_PEERSTORE_Handle *h;
33 static char *ss = "test_peerstore_stress";
34 static struct GNUNET_PeerIdentity p;
35 static char *k = "test_peerstore_stress_key";
36 static char *v = "test_peerstore_stress_val";
44 GNUNET_PEERSTORE_disconnect (h, GNUNET_YES);
45 GNUNET_SCHEDULER_shutdown ();
52 GNUNET_PEERSTORE_store (h, ss, &p, k, v, strlen (v) + 1,
53 GNUNET_TIME_UNIT_FOREVER_ABS,
55 0) ? GNUNET_PEERSTORE_STOREOPTION_REPLACE :
56 GNUNET_PEERSTORE_STOREOPTION_MULTIPLE, NULL, NULL);
62 watch_cb (void *cls, const struct GNUNET_PEERSTORE_Record *record,
65 GNUNET_assert (NULL == emsg);
77 run (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg,
78 struct GNUNET_TESTING_Peer *peer)
80 memset (&p, 5, sizeof (p));
81 h = GNUNET_PEERSTORE_connect (cfg);
82 GNUNET_assert (NULL != h);
83 GNUNET_PEERSTORE_watch (h, ss, &p, k, &watch_cb, NULL);
89 main (int argc, char *argv[])
91 struct GNUNET_TIME_Absolute start;
92 struct GNUNET_TIME_Relative diff;
94 start = GNUNET_TIME_absolute_get ();
96 GNUNET_TESTING_service_run ("perf-peerstore-store", "peerstore",
97 "test_peerstore_api_data.conf", &run, NULL))
99 diff = GNUNET_TIME_absolute_get_duration (start);
100 fprintf (stderr, "Stored and retrieved %d records in %s (%s).\n", STORES,
101 GNUNET_STRINGS_relative_time_to_string (diff, GNUNET_YES),
102 GNUNET_STRINGS_relative_time_to_string (diff, GNUNET_NO));
106 /* end of perf_peerstore_store.c */