2 This file is part of GNUnet.
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your
8 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 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
21 * @file peerstore/perf_peerstore_store.c
22 * @brief performance test for peerstore store operation
25 #include "gnunet_util_lib.h"
26 #include "gnunet_testing_lib.h"
27 #include "gnunet_peerstore_service.h"
33 static struct GNUNET_PEERSTORE_Handle *h;
35 static char *ss = "test_peerstore_stress";
36 static struct GNUNET_PeerIdentity p;
37 static char *k = "test_peerstore_stress_key";
38 static char *v = "test_peerstore_stress_val";
46 GNUNET_PEERSTORE_disconnect (h, GNUNET_YES);
47 GNUNET_SCHEDULER_shutdown ();
54 GNUNET_PEERSTORE_store (h, ss, &p, k, v, strlen (v) + 1,
55 GNUNET_TIME_UNIT_FOREVER_ABS,
57 0) ? GNUNET_PEERSTORE_STOREOPTION_REPLACE :
58 GNUNET_PEERSTORE_STOREOPTION_MULTIPLE, NULL, NULL);
64 watch_cb (void *cls, const struct GNUNET_PEERSTORE_Record *record,
67 GNUNET_assert (NULL == emsg);
79 run (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg,
80 struct GNUNET_TESTING_Peer *peer)
82 memset (&p, 5, sizeof (p));
83 h = GNUNET_PEERSTORE_connect (cfg);
84 GNUNET_assert (NULL != h);
85 GNUNET_PEERSTORE_watch (h, ss, &p, k, &watch_cb, NULL);
91 main (int argc, char *argv[])
93 struct GNUNET_TIME_Absolute start;
94 struct GNUNET_TIME_Relative diff;
96 start = GNUNET_TIME_absolute_get ();
98 GNUNET_TESTING_service_run ("perf-peerstore-store", "peerstore",
99 "test_peerstore_api_data.conf", &run, NULL))
101 diff = GNUNET_TIME_absolute_get_duration (start);
102 fprintf (stderr, "Stored and retrieved %d records in %s (%s).\n", STORES,
103 GNUNET_STRINGS_relative_time_to_string (diff, GNUNET_YES),
104 GNUNET_STRINGS_relative_time_to_string (diff, GNUNET_NO));
108 /* end of perf_peerstore_store.c */