diff options
Diffstat (limited to 'src/peerstore/perf_peerstore_store.c')
-rw-r--r-- | src/peerstore/perf_peerstore_store.c | 68 |
1 files changed, 34 insertions, 34 deletions
diff --git a/src/peerstore/perf_peerstore_store.c b/src/peerstore/perf_peerstore_store.c index 51761cc4f..392dbbb03 100644 --- a/src/peerstore/perf_peerstore_store.c +++ b/src/peerstore/perf_peerstore_store.c | |||
@@ -11,12 +11,12 @@ | |||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Affero General Public License for more details. | 13 | Affero General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Affero General Public License | 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/>. | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | 17 | ||
18 | SPDX-License-Identifier: AGPL3.0-or-later | 18 | SPDX-License-Identifier: AGPL3.0-or-later |
19 | */ | 19 | */ |
20 | /** | 20 | /** |
21 | * @file peerstore/perf_peerstore_store.c | 21 | * @file peerstore/perf_peerstore_store.c |
22 | * @brief performance test for peerstore store operation | 22 | * @brief performance test for peerstore store operation |
@@ -40,68 +40,68 @@ static char *v = "test_peerstore_stress_val"; | |||
40 | static int count = 0; | 40 | static int count = 0; |
41 | 41 | ||
42 | static void | 42 | static void |
43 | disconnect () | 43 | disconnect() |
44 | { | 44 | { |
45 | if (NULL != h) | 45 | if (NULL != h) |
46 | GNUNET_PEERSTORE_disconnect (h, GNUNET_YES); | 46 | GNUNET_PEERSTORE_disconnect(h, GNUNET_YES); |
47 | GNUNET_SCHEDULER_shutdown (); | 47 | GNUNET_SCHEDULER_shutdown(); |
48 | } | 48 | } |
49 | 49 | ||
50 | 50 | ||
51 | static void | 51 | static void |
52 | store () | 52 | store() |
53 | { | 53 | { |
54 | GNUNET_PEERSTORE_store (h, ss, &p, k, v, strlen (v) + 1, | 54 | GNUNET_PEERSTORE_store(h, ss, &p, k, v, strlen(v) + 1, |
55 | GNUNET_TIME_UNIT_FOREVER_ABS, | 55 | GNUNET_TIME_UNIT_FOREVER_ABS, |
56 | (count == | 56 | (count == |
57 | 0) ? GNUNET_PEERSTORE_STOREOPTION_REPLACE : | 57 | 0) ? GNUNET_PEERSTORE_STOREOPTION_REPLACE : |
58 | GNUNET_PEERSTORE_STOREOPTION_MULTIPLE, NULL, NULL); | 58 | GNUNET_PEERSTORE_STOREOPTION_MULTIPLE, NULL, NULL); |
59 | count++; | 59 | count++; |
60 | } | 60 | } |
61 | 61 | ||
62 | 62 | ||
63 | static void | 63 | static void |
64 | watch_cb (void *cls, const struct GNUNET_PEERSTORE_Record *record, | 64 | watch_cb(void *cls, const struct GNUNET_PEERSTORE_Record *record, |
65 | const char *emsg) | 65 | const char *emsg) |
66 | { | 66 | { |
67 | GNUNET_assert (NULL == emsg); | 67 | GNUNET_assert(NULL == emsg); |
68 | if (STORES == count) | 68 | if (STORES == count) |
69 | { | 69 | { |
70 | ok = 0; | 70 | ok = 0; |
71 | disconnect (); | 71 | disconnect(); |
72 | } | 72 | } |
73 | else | 73 | else |
74 | store (); | 74 | store(); |
75 | } | 75 | } |
76 | 76 | ||
77 | 77 | ||
78 | static void | 78 | static void |
79 | run (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg, | 79 | run(void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg, |
80 | struct GNUNET_TESTING_Peer *peer) | 80 | struct GNUNET_TESTING_Peer *peer) |
81 | { | 81 | { |
82 | memset (&p, 5, sizeof (p)); | 82 | memset(&p, 5, sizeof(p)); |
83 | h = GNUNET_PEERSTORE_connect (cfg); | 83 | h = GNUNET_PEERSTORE_connect(cfg); |
84 | GNUNET_assert (NULL != h); | 84 | GNUNET_assert(NULL != h); |
85 | GNUNET_PEERSTORE_watch (h, ss, &p, k, &watch_cb, NULL); | 85 | GNUNET_PEERSTORE_watch(h, ss, &p, k, &watch_cb, NULL); |
86 | store (); | 86 | store(); |
87 | } | 87 | } |
88 | 88 | ||
89 | 89 | ||
90 | int | 90 | int |
91 | main (int argc, char *argv[]) | 91 | main(int argc, char *argv[]) |
92 | { | 92 | { |
93 | struct GNUNET_TIME_Absolute start; | 93 | struct GNUNET_TIME_Absolute start; |
94 | struct GNUNET_TIME_Relative diff; | 94 | struct GNUNET_TIME_Relative diff; |
95 | 95 | ||
96 | start = GNUNET_TIME_absolute_get (); | 96 | start = GNUNET_TIME_absolute_get(); |
97 | if (0 != | 97 | if (0 != |
98 | GNUNET_TESTING_service_run ("perf-peerstore-store", "peerstore", | 98 | GNUNET_TESTING_service_run("perf-peerstore-store", "peerstore", |
99 | "test_peerstore_api_data.conf", &run, NULL)) | 99 | "test_peerstore_api_data.conf", &run, NULL)) |
100 | return 1; | 100 | return 1; |
101 | diff = GNUNET_TIME_absolute_get_duration (start); | 101 | diff = GNUNET_TIME_absolute_get_duration(start); |
102 | fprintf (stderr, "Stored and retrieved %d records in %s (%s).\n", STORES, | 102 | fprintf(stderr, "Stored and retrieved %d records in %s (%s).\n", STORES, |
103 | GNUNET_STRINGS_relative_time_to_string (diff, GNUNET_YES), | 103 | GNUNET_STRINGS_relative_time_to_string(diff, GNUNET_YES), |
104 | GNUNET_STRINGS_relative_time_to_string (diff, GNUNET_NO)); | 104 | GNUNET_STRINGS_relative_time_to_string(diff, GNUNET_NO)); |
105 | return ok; | 105 | return ok; |
106 | } | 106 | } |
107 | 107 | ||