diff options
author | Christian Grothoff <christian@grothoff.org> | 2009-07-17 10:36:53 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2009-07-17 10:36:53 +0000 |
commit | 7bf136782e1fb5bf89780c86596692de625e26a3 (patch) | |
tree | 1cd91008e5db1a58cbff6e3cf0f7496d23aea9d6 /src/datastore | |
parent | 1889ea5dae621980f611b196e3f574c11c2ac881 (diff) | |
download | gnunet-7bf136782e1fb5bf89780c86596692de625e26a3.tar.gz gnunet-7bf136782e1fb5bf89780c86596692de625e26a3.zip |
stuff
Diffstat (limited to 'src/datastore')
-rw-r--r-- | src/datastore/perf_datastore_api.c | 120 | ||||
-rw-r--r-- | src/datastore/test_datastore_api.c | 2 |
2 files changed, 101 insertions, 21 deletions
diff --git a/src/datastore/perf_datastore_api.c b/src/datastore/perf_datastore_api.c index 5813634d9..89b829d7f 100644 --- a/src/datastore/perf_datastore_api.c +++ b/src/datastore/perf_datastore_api.c | |||
@@ -111,7 +111,6 @@ static struct GNUNET_TIME_Absolute start_time; | |||
111 | 111 | ||
112 | static int ok; | 112 | static int ok; |
113 | 113 | ||
114 | |||
115 | static int | 114 | static int |
116 | putValue (int i, int k) | 115 | putValue (int i, int k) |
117 | { | 116 | { |
@@ -171,33 +170,81 @@ iterate_delete (void *cls, | |||
171 | } | 170 | } |
172 | 171 | ||
173 | 172 | ||
173 | enum RunPhase | ||
174 | { | ||
175 | RP_DONE = 0, | ||
176 | RP_PUT, | ||
177 | RP_CUT, | ||
178 | RP_REPORT, | ||
179 | RP_END | ||
180 | }; | ||
174 | 181 | ||
175 | static void | 182 | |
176 | run (void *cls, | 183 | struct CpsRunContext |
177 | struct GNUNET_SCHEDULER_Handle *sched, | ||
178 | char *const *args, | ||
179 | const char *cfgfile, struct GNUNET_CONFIGURATION_Handle *cfg) | ||
180 | { | 184 | { |
185 | struct GNUNET_SCHEDULER_Handle *sched; | ||
186 | struct GNUNET_CONFIGURATION_Handle *cfg; | ||
187 | enum RunPhase phase; | ||
181 | int j; | 188 | int j; |
182 | unsigned long long size; | 189 | unsigned long long size; |
183 | int i; | 190 | int i; |
184 | 191 | ||
185 | datastore = GNUNET_DATASTORE_connect (cfg, sched); | ||
186 | /* FIXME: change loop to use CPS; current | ||
187 | datastore API will likely react negative to | ||
188 | us ignoring the callbacks... */ | ||
189 | for (i = 0; i < ITERATIONS; i++) | ||
190 | { | ||
191 | #if REPORT_ID | ||
192 | fprintf (stderr, "."); | ||
193 | #endif | ||
194 | /* insert data equivalent to 1/10th of MAX_SIZE */ | ||
195 | for (j = 0; j < PUT_10; j++) | ||
196 | GNUNET_assert (GNUNET_OK == putValue (j, i)); | ||
197 | 192 | ||
193 | GNUNET_HashCode key; | ||
194 | int *iptr; | ||
195 | }; | ||
196 | |||
197 | |||
198 | |||
199 | static void | ||
200 | run_continuation (void *cls, | ||
201 | const struct GNUNET_SCHEDULER_TaskContext *tc); | ||
202 | |||
203 | |||
204 | |||
205 | static void | ||
206 | run_continuation (void *cls, | ||
207 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
208 | { | ||
209 | struct CpsRunContext *crc = cls; | ||
210 | ok = (int) crc->phase; | ||
211 | switch (crc->phase) | ||
212 | { | ||
213 | case RP_PUT: | ||
214 | memset (&crc->key, 256 - crc->i, sizeof (GNUNET_HashCode)); | ||
215 | |||
216 | GNUNET_assert (GNUNET_OK == putValue (j, i)); | ||
217 | GNUNET_DATASTORE_put (datastore, | ||
218 | 0, | ||
219 | &crc->key, | ||
220 | get_size (crc->i), | ||
221 | get_data (crc->i), | ||
222 | get_type (crc->i), | ||
223 | get_priority (crc->i), | ||
224 | get_anonymity (crc->i), | ||
225 | get_expiration (crc->i), | ||
226 | TIMEOUT, | ||
227 | &check_success, | ||
228 | crc); | ||
229 | crc->j++; | ||
230 | if (crc->j < PUT_10) | ||
231 | break; | ||
232 | crc->j = 0; | ||
233 | crc->i++; | ||
234 | if (crc->i == ITERATIONS) | ||
235 | crc->phase = RP_DONE; | ||
236 | else | ||
237 | crc->phase = RP_CUT; | ||
238 | break; | ||
239 | case RP_CUT: | ||
198 | /* trim down below MAX_SIZE again */ | 240 | /* trim down below MAX_SIZE again */ |
199 | if ((i % 2) == 0) | 241 | if ((i % 2) == 0) |
200 | GNUNET_DATASTORE_get_random (datastore, &iterate_delete, NULL); | 242 | GNUNET_DATASTORE_get_random (datastore, |
243 | &iterate_delete, | ||
244 | NULL); | ||
245 | crc->phase = RP_REPORT; | ||
246 | break; | ||
247 | case RP_REPORT: | ||
201 | size = 0; | 248 | size = 0; |
202 | printf ( | 249 | printf ( |
203 | #if REPORT_ID | 250 | #if REPORT_ID |
@@ -207,8 +254,41 @@ run (void *cls, | |||
207 | stored_bytes / 1024, /* used size in k */ | 254 | stored_bytes / 1024, /* used size in k */ |
208 | (stored_ops * 2 - stored_entries) / 1024, /* total operations (in k) */ | 255 | (stored_ops * 2 - stored_entries) / 1024, /* total operations (in k) */ |
209 | 1000 * (stored_ops * 2 - stored_entries) / (1 + GNUNET_TIME_absolute_get_duration(start_time).value)); /* operations per second */ | 256 | 1000 * (stored_ops * 2 - stored_entries) / (1 + GNUNET_TIME_absolute_get_duration(start_time).value)); /* operations per second */ |
257 | crc->phase = RP_PUT; | ||
258 | // fixme: trigger next round... | ||
259 | GNUNET_SCHEDULER_add_continuation (crc->sched, | ||
260 | GNUNET_NO, | ||
261 | &run_continuation, | ||
262 | crc, | ||
263 | GNUNET_SCHEDULER_REASON_PREREQ_DONE); | ||
264 | break; | ||
265 | case RP_DONE: | ||
266 | GNUNET_DATASTORE_disconnect (datastore, GNUNET_YES); | ||
267 | ok = 0; | ||
268 | break; | ||
210 | } | 269 | } |
211 | GNUNET_DATASTORE_disconnect (datastore, GNUNET_YES); | 270 | } |
271 | |||
272 | |||
273 | static void | ||
274 | run (void *cls, | ||
275 | struct GNUNET_SCHEDULER_Handle *sched, | ||
276 | char *const *args, | ||
277 | const char *cfgfile, struct GNUNET_CONFIGURATION_Handle *cfg) | ||
278 | { | ||
279 | struct CpsRunContext *crc; | ||
280 | |||
281 | datastore = GNUNET_DATASTORE_connect (cfg, sched); | ||
282 | |||
283 | crc = GNUNET_malloc(sizeof(struct CpsRunContext)); | ||
284 | crc->sched = sched; | ||
285 | crc->cfg = cfg; | ||
286 | crc->phase = RP_PUT; | ||
287 | GNUNET_SCHEDULER_add_continuation (crc->sched, | ||
288 | GNUNET_NO, | ||
289 | &run_continuation, | ||
290 | crc, | ||
291 | GNUNET_SCHEDULER_REASON_PREREQ_DONE); | ||
212 | } | 292 | } |
213 | 293 | ||
214 | 294 | ||
diff --git a/src/datastore/test_datastore_api.c b/src/datastore/test_datastore_api.c index 28fc12ef6..353050a53 100644 --- a/src/datastore/test_datastore_api.c +++ b/src/datastore/test_datastore_api.c | |||
@@ -82,7 +82,7 @@ get_anonymity(int i) | |||
82 | } | 82 | } |
83 | 83 | ||
84 | 84 | ||
85 | static struct GNUNET_TIME_Absolute | 85 | tatic struct GNUNET_TIME_Absolute |
86 | get_expiration (int i) | 86 | get_expiration (int i) |
87 | { | 87 | { |
88 | struct GNUNET_TIME_Absolute av; | 88 | struct GNUNET_TIME_Absolute av; |