diff options
author | Christian Grothoff <christian@grothoff.org> | 2017-02-26 00:50:35 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2017-02-26 00:50:35 +0100 |
commit | a5899842ad354a8fde6230dc77338f7232d4881c (patch) | |
tree | 3cb77d9ccdeb79b22897339e3cc254a24f221e58 /src/peerinfo/perf_peerinfo_api.c | |
parent | eb1c2236158eba266de1bc91d75d9c6d0714252b (diff) | |
download | gnunet-a5899842ad354a8fde6230dc77338f7232d4881c.tar.gz gnunet-a5899842ad354a8fde6230dc77338f7232d4881c.zip |
fix perf_peerinfo_api FTBFS
Diffstat (limited to 'src/peerinfo/perf_peerinfo_api.c')
-rw-r--r-- | src/peerinfo/perf_peerinfo_api.c | 93 |
1 files changed, 70 insertions, 23 deletions
diff --git a/src/peerinfo/perf_peerinfo_api.c b/src/peerinfo/perf_peerinfo_api.c index d446cbe3f..840c85c1b 100644 --- a/src/peerinfo/perf_peerinfo_api.c +++ b/src/peerinfo/perf_peerinfo_api.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2004, 2009, 2010 GNUnet e.V. | 3 | Copyright (C) 2004, 2009, 2010, 2017 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software; you can redistribute it and/or modify | 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 | 6 | it under the terms of the GNU General Public License as published |
@@ -22,7 +22,7 @@ | |||
22 | * @file peerinfo/perf_peerinfo_api.c | 22 | * @file peerinfo/perf_peerinfo_api.c |
23 | * @brief testcase for peerinfo_api.c, hopefully hammer the peerinfo service, | 23 | * @brief testcase for peerinfo_api.c, hopefully hammer the peerinfo service, |
24 | * this performance test adds up to 5000 peers with one address each and checks | 24 | * this performance test adds up to 5000 peers with one address each and checks |
25 | * over how many peers it can iterate before receiving a timeout after 30 seconds | 25 | * over how many peers it can iterate before receiving a timeout after 5 seconds |
26 | * @author Nathan Evans | 26 | * @author Nathan Evans |
27 | */ | 27 | */ |
28 | 28 | ||
@@ -34,8 +34,6 @@ | |||
34 | #include "peerinfo.h" | 34 | #include "peerinfo.h" |
35 | #include <gauger.h> | 35 | #include <gauger.h> |
36 | 36 | ||
37 | #define START_SERVICE 1 | ||
38 | |||
39 | #define NUM_REQUESTS 5000 | 37 | #define NUM_REQUESTS 5000 |
40 | 38 | ||
41 | static struct GNUNET_PEERINFO_IteratorContext *ic[NUM_REQUESTS]; | 39 | static struct GNUNET_PEERINFO_IteratorContext *ic[NUM_REQUESTS]; |
@@ -46,9 +44,36 @@ static unsigned int numpeers; | |||
46 | 44 | ||
47 | static struct GNUNET_PeerIdentity pid; | 45 | static struct GNUNET_PeerIdentity pid; |
48 | 46 | ||
47 | static struct GNUNET_SCHEDULER_Task *tt; | ||
48 | |||
49 | |||
50 | static void | ||
51 | do_shutdown (void *cls) | ||
52 | { | ||
53 | if (NULL != tt) | ||
54 | { | ||
55 | GNUNET_SCHEDULER_cancel (tt); | ||
56 | tt = NULL; | ||
57 | } | ||
58 | for (unsigned int i = 0; i < NUM_REQUESTS; i++) | ||
59 | if (NULL != ic[i]) | ||
60 | GNUNET_PEERINFO_iterate_cancel (ic[i]); | ||
61 | GNUNET_PEERINFO_disconnect (h); | ||
62 | h = NULL; | ||
63 | } | ||
64 | |||
65 | |||
66 | static void | ||
67 | do_timeout (void *cls) | ||
68 | { | ||
69 | tt = NULL; | ||
70 | GNUNET_SCHEDULER_shutdown (); | ||
71 | } | ||
72 | |||
49 | 73 | ||
50 | static int | 74 | static int |
51 | check_it (void *cls, const struct GNUNET_HELLO_Address *address, | 75 | check_it (void *cls, |
76 | const struct GNUNET_HELLO_Address *address, | ||
52 | struct GNUNET_TIME_Absolute expiration) | 77 | struct GNUNET_TIME_Absolute expiration) |
53 | { | 78 | { |
54 | return GNUNET_OK; | 79 | return GNUNET_OK; |
@@ -87,23 +112,34 @@ add_peer (size_t i) | |||
87 | struct GNUNET_HELLO_Message *h2; | 112 | struct GNUNET_HELLO_Message *h2; |
88 | 113 | ||
89 | memset (&pid, i, sizeof (pid)); | 114 | memset (&pid, i, sizeof (pid)); |
90 | h2 = GNUNET_HELLO_create (&pid.public_key, &address_generator, &i, GNUNET_NO); | 115 | h2 = GNUNET_HELLO_create (&pid.public_key, |
116 | &address_generator, | ||
117 | &i, | ||
118 | GNUNET_NO); | ||
91 | GNUNET_PEERINFO_add_peer (h, h2, NULL, NULL); | 119 | GNUNET_PEERINFO_add_peer (h, h2, NULL, NULL); |
92 | GNUNET_free (h2); | 120 | GNUNET_free (h2); |
93 | } | 121 | } |
94 | 122 | ||
95 | 123 | ||
96 | static void | 124 | static void |
97 | process (void *cls, const struct GNUNET_PeerIdentity *peer, | 125 | process (void *cls, |
98 | const struct GNUNET_HELLO_Message *hello, const char *err_msg) | 126 | const struct GNUNET_PeerIdentity *peer, |
127 | const struct GNUNET_HELLO_Message *hello, | ||
128 | const char *err_msg) | ||
99 | { | 129 | { |
100 | if (NULL != peer) | 130 | struct GNUNET_PEERINFO_IteratorContext **icp = cls; |
101 | { | ||
102 | numpeers++; | ||
103 | if (0 && (hello != NULL)) | ||
104 | GNUNET_HELLO_iterate_addresses (hello, GNUNET_NO, &check_it, NULL); | ||
105 | 131 | ||
132 | if (NULL == peer) | ||
133 | { | ||
134 | *icp = NULL; | ||
135 | return; | ||
106 | } | 136 | } |
137 | numpeers++; | ||
138 | if (0 && (NULL != hello) ) | ||
139 | GNUNET_HELLO_iterate_addresses (hello, | ||
140 | GNUNET_NO, | ||
141 | &check_it, | ||
142 | NULL); | ||
107 | } | 143 | } |
108 | 144 | ||
109 | 145 | ||
@@ -112,32 +148,43 @@ run (void *cls, | |||
112 | const struct GNUNET_CONFIGURATION_Handle *cfg, | 148 | const struct GNUNET_CONFIGURATION_Handle *cfg, |
113 | struct GNUNET_TESTING_Peer *peer) | 149 | struct GNUNET_TESTING_Peer *peer) |
114 | { | 150 | { |
115 | size_t i; | ||
116 | |||
117 | h = GNUNET_PEERINFO_connect (cfg); | 151 | h = GNUNET_PEERINFO_connect (cfg); |
118 | GNUNET_assert (h != NULL); | 152 | GNUNET_assert (h != NULL); |
119 | for (i = 0; i < NUM_REQUESTS; i++) | 153 | for (unsigned int i = 0; i < NUM_REQUESTS; i++) |
120 | { | 154 | { |
121 | add_peer (i); | 155 | add_peer (i); |
122 | ic[i] = | 156 | ic[i] = GNUNET_PEERINFO_iterate (h, |
123 | GNUNET_PEERINFO_iterate (h, GNUNET_YES, NULL, | 157 | GNUNET_YES, |
124 | GNUNET_TIME_relative_multiply | 158 | NULL, |
125 | (GNUNET_TIME_UNIT_SECONDS, 30), &process, cls); | 159 | &process, |
160 | &ic[i]); | ||
126 | } | 161 | } |
162 | tt = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, | ||
163 | 5), | ||
164 | &do_timeout, | ||
165 | NULL); | ||
166 | GNUNET_SCHEDULER_add_shutdown (&do_shutdown, | ||
167 | NULL); | ||
127 | } | 168 | } |
128 | 169 | ||
129 | 170 | ||
130 | int | 171 | int |
131 | main (int argc, char *argv[]) | 172 | main (int argc, |
173 | char *argv[]) | ||
132 | { | 174 | { |
133 | if (0 != GNUNET_TESTING_service_run ("perf-gnunet-peerinfo", | 175 | if (0 != GNUNET_TESTING_service_run ("perf-gnunet-peerinfo", |
134 | "peerinfo", | 176 | "peerinfo", |
135 | "test_peerinfo_api_data.conf", | 177 | "test_peerinfo_api_data.conf", |
136 | &run, NULL)) | 178 | &run, NULL)) |
137 | return 1; | 179 | return 1; |
138 | FPRINTF (stderr, "Received %u/%u calls before timeout\n", numpeers, | 180 | FPRINTF (stderr, |
181 | "Received %u/%u calls before timeout\n", | ||
182 | numpeers, | ||
139 | NUM_REQUESTS * NUM_REQUESTS / 2); | 183 | NUM_REQUESTS * NUM_REQUESTS / 2); |
140 | GAUGER ("PEERINFO", "Peerinfo lookups", numpeers / 30, "peers/s"); | 184 | GAUGER ("PEERINFO", |
185 | "Peerinfo lookups", | ||
186 | numpeers / 5, | ||
187 | "peers/s"); | ||
141 | return 0; | 188 | return 0; |
142 | } | 189 | } |
143 | 190 | ||