aboutsummaryrefslogtreecommitdiff
path: root/src/service/namestore/perf_namestore_api_import.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/service/namestore/perf_namestore_api_import.c')
-rw-r--r--src/service/namestore/perf_namestore_api_import.c108
1 files changed, 42 insertions, 66 deletions
diff --git a/src/service/namestore/perf_namestore_api_import.c b/src/service/namestore/perf_namestore_api_import.c
index bf8093f43..faa75b5ab 100644
--- a/src/service/namestore/perf_namestore_api_import.c
+++ b/src/service/namestore/perf_namestore_api_import.c
@@ -22,10 +22,8 @@
22 * @brief testcase for namestore: Import a lot of records 22 * @brief testcase for namestore: Import a lot of records
23 * @author Martin Schanzenbach 23 * @author Martin Schanzenbach
24 */ 24 */
25#include "platform.h"
26#include "gnunet_namestore_service.h" 25#include "gnunet_namestore_service.h"
27#include "gnunet_testing_lib.h" 26#include "gnunet_testing_lib.h"
28#include "../service/namestore/namestore.h"
29 27
30#define TEST_RECORD_TYPE GNUNET_DNSPARSER_TYPE_TXT 28#define TEST_RECORD_TYPE GNUNET_DNSPARSER_TYPE_TXT
31 29
@@ -149,31 +147,6 @@ static void
149publish_records_single (void *cls); 147publish_records_single (void *cls);
150 148
151static void 149static void
152commit_cont (void *cls,
153 enum GNUNET_ErrorCode ec)
154{
155 struct GNUNET_TIME_Relative delay;
156
157 (void) cls;
158 qe = NULL;
159 if (GNUNET_EC_NONE != ec)
160 {
161 GNUNET_break (0);
162 GNUNET_SCHEDULER_shutdown ();
163 return;
164 }
165 single_put_pos++;
166 delay = GNUNET_TIME_absolute_get_duration (start);
167 fprintf (stdout,
168 "BULK-TX: Publishing %u records took %s\n",
169 TEST_RECORD_COUNT,
170 GNUNET_STRINGS_relative_time_to_string (delay,
171 GNUNET_YES));
172 res = 0;
173 GNUNET_SCHEDULER_shutdown ();
174}
175
176static void
177publish_records_bulk_tx (void *cls); 150publish_records_bulk_tx (void *cls);
178 151
179 152
@@ -181,6 +154,7 @@ static void
181put_cont_bulk_tx (void *cls, 154put_cont_bulk_tx (void *cls,
182 enum GNUNET_ErrorCode ec) 155 enum GNUNET_ErrorCode ec)
183{ 156{
157 struct GNUNET_TIME_Relative delay;
184 qe = NULL; 158 qe = NULL;
185 if (GNUNET_EC_NONE != ec) 159 if (GNUNET_EC_NONE != ec)
186 { 160 {
@@ -190,7 +164,15 @@ put_cont_bulk_tx (void *cls,
190 } 164 }
191 if (bulk_count == TEST_RECORD_COUNT) 165 if (bulk_count == TEST_RECORD_COUNT)
192 { 166 {
193 qe = GNUNET_NAMESTORE_transaction_commit (nsh, commit_cont, NULL); 167 single_put_pos++;
168 delay = GNUNET_TIME_absolute_get_duration (start);
169 fprintf (stdout,
170 "BULK-TX: Publishing %u records took %s\n",
171 TEST_RECORD_COUNT,
172 GNUNET_STRINGS_relative_time_to_string (delay,
173 GNUNET_YES));
174 res = 0;
175 GNUNET_SCHEDULER_shutdown ();
194 return; 176 return;
195 } 177 }
196 t = GNUNET_SCHEDULER_add_now (&publish_records_bulk_tx, NULL); 178 t = GNUNET_SCHEDULER_add_now (&publish_records_bulk_tx, NULL);
@@ -202,35 +184,19 @@ publish_records_bulk_tx (void *cls)
202{ 184{
203 unsigned int sent_rds; 185 unsigned int sent_rds;
204 t = NULL; 186 t = NULL;
205 qe = GNUNET_NAMESTORE_records_store2 (nsh, 187 qe = GNUNET_NAMESTORE_records_store (nsh,
206 &privkey, 188 &privkey,
207 TEST_RECORD_COUNT - bulk_count, 189 TEST_RECORD_COUNT - bulk_count,
208 &ri[bulk_count], 190 &ri[bulk_count],
209 &sent_rds, 191 &sent_rds,
210 &put_cont_bulk_tx, 192 &put_cont_bulk_tx,
211 NULL); 193 NULL);
212 bulk_count += sent_rds; 194 bulk_count += sent_rds;
213 GNUNET_assert (sent_rds != 0); 195 GNUNET_assert (sent_rds != 0);
214} 196}
215 197
216 198
217static void 199static void
218begin_cont (void *cls,
219 enum GNUNET_ErrorCode ec)
220{
221 unsigned int sent_rds;
222 qe = GNUNET_NAMESTORE_records_store2 (nsh,
223 &privkey,
224 TEST_RECORD_COUNT - bulk_count,
225 &ri[bulk_count],
226 &sent_rds,
227 &put_cont_bulk_tx,
228 NULL);
229 bulk_count += sent_rds;
230 GNUNET_assert (sent_rds != 0);
231}
232
233static void
234publish_records_bulk (void *cls); 200publish_records_bulk (void *cls);
235 201
236static void 202static void
@@ -238,6 +204,7 @@ put_cont_bulk (void *cls,
238 enum GNUNET_ErrorCode ec) 204 enum GNUNET_ErrorCode ec)
239{ 205{
240 struct GNUNET_TIME_Relative delay; 206 struct GNUNET_TIME_Relative delay;
207 unsigned int sent_rds;
241 208
242 (void) cls; 209 (void) cls;
243 qe = NULL; 210 qe = NULL;
@@ -258,7 +225,15 @@ put_cont_bulk (void *cls,
258 GNUNET_YES)); 225 GNUNET_YES));
259 start = GNUNET_TIME_absolute_get (); 226 start = GNUNET_TIME_absolute_get ();
260 bulk_count = 0; 227 bulk_count = 0;
261 qe = GNUNET_NAMESTORE_transaction_begin (nsh, begin_cont, NULL); 228 qe = GNUNET_NAMESTORE_records_store (nsh,
229 &privkey,
230 TEST_RECORD_COUNT - bulk_count,
231 &ri[bulk_count],
232 &sent_rds,
233 &put_cont_bulk_tx,
234 NULL);
235 bulk_count += sent_rds;
236 GNUNET_assert (sent_rds != 0);
262 return; 237 return;
263 } 238 }
264 (void) cls; 239 (void) cls;
@@ -272,19 +247,20 @@ put_cont_bulk (void *cls,
272 t = GNUNET_SCHEDULER_add_now (&publish_records_bulk, NULL); 247 t = GNUNET_SCHEDULER_add_now (&publish_records_bulk, NULL);
273} 248}
274 249
250
275static void 251static void
276publish_records_bulk (void *cls) 252publish_records_bulk (void *cls)
277{ 253{
278 static unsigned int sent_rds = 0; 254 static unsigned int sent_rds = 0;
279 (void) cls; 255 (void) cls;
280 t = NULL; 256 t = NULL;
281 qe = GNUNET_NAMESTORE_records_store2 (nsh, 257 qe = GNUNET_NAMESTORE_records_store (nsh,
282 &privkey, 258 &privkey,
283 TEST_RECORD_COUNT - bulk_count, 259 TEST_RECORD_COUNT - bulk_count,
284 &ri[bulk_count], 260 &ri[bulk_count],
285 &sent_rds, 261 &sent_rds,
286 &put_cont_bulk, 262 &put_cont_bulk,
287 NULL); 263 NULL);
288 bulk_count += sent_rds; 264 bulk_count += sent_rds;
289 GNUNET_assert (sent_rds != 0); 265 GNUNET_assert (sent_rds != 0);
290} 266}
@@ -338,13 +314,13 @@ publish_records_single (void *cls)
338 GNUNET_YES)); 314 GNUNET_YES));
339 GNUNET_SCHEDULER_add_now (&publish_records_bulk, NULL); 315 GNUNET_SCHEDULER_add_now (&publish_records_bulk, NULL);
340 } 316 }
341 qe = GNUNET_NAMESTORE_records_store (nsh, 317 qe = GNUNET_NAMESTORE_record_set_store (nsh,
342 &privkey, 318 &privkey,
343 ri[single_put_pos].a_label, 319 ri[single_put_pos].a_label,
344 ri[single_put_pos].a_rd_count, 320 ri[single_put_pos].a_rd_count,
345 ri[single_put_pos].a_rd, 321 ri[single_put_pos].a_rd,
346 &put_cont_single, 322 &put_cont_single,
347 NULL); 323 NULL);
348} 324}
349 325
350 326