aboutsummaryrefslogtreecommitdiff
path: root/src/exchangedb/perf_taler_exchangedb_interpreter.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/exchangedb/perf_taler_exchangedb_interpreter.h')
-rw-r--r--src/exchangedb/perf_taler_exchangedb_interpreter.h1145
1 files changed, 0 insertions, 1145 deletions
diff --git a/src/exchangedb/perf_taler_exchangedb_interpreter.h b/src/exchangedb/perf_taler_exchangedb_interpreter.h
deleted file mode 100644
index 414e33fe0..000000000
--- a/src/exchangedb/perf_taler_exchangedb_interpreter.h
+++ /dev/null
@@ -1,1145 +0,0 @@
1/*
2 This file is part of TALER
3 Copyright (C) 2014, 2015 GNUnet e.V.
4
5 TALER is free software; you can redistribute it and/or modify it under the
6 terms of the GNU General Public License as published by the Free Software
7 Foundation; either version 3, or (at your option) any later version.
8
9 TALER is distributed in the hope that it will be useful, but WITHOUT ANY
10 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12
13 You should have received a copy of the GNU General Public License along with
14 TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
15*/
16/**
17 * @file exchangedb/perf_taler_exchangedb_interpreter.h
18 * @brief Library for performance analysis of the Taler database
19 * @author Nicolas Fournier
20 *
21 * This library contains functions and macro alowing Taler performance analysis
22 * to be written with ease.
23 * To do so, create a #PERF_TALER_EXCHANGEDB_Cmd array and fill it with the commands
24 * to execute in chronological order. Some command have an exposed variable wich
25 * can be reused in other commands.
26 * Macros are available to make the use much easier so feel free to use them
27 * to initialize your own command array.
28 */
29
30#ifndef __PERF_TALER_EXCHANGEDB_INTERPRETER_H__
31#define __PERF_TALER_EXCHANGEDB_INTERPRETER_H__
32
33#include <sys/time.h>
34#include "taler_exchangedb_plugin.h"
35
36
37#define PERF_TALER_EXCHANGEDB_NB_DENOMINATION_INIT 10
38#define PERF_TALER_EXCHANGEDB_NB_DENOMINATION_SAVE 10
39
40#define PERF_TALER_EXCHANGEDB_NB_RESERVE_INIT 100
41#define PERF_TALER_EXCHANGEDB_NB_RESERVE_SAVE 10
42
43#define PERF_TALER_EXCHANGEDB_NB_DEPOSIT_INIT 100
44#define PERF_TALER_EXCHANGEDB_NB_DEPOSIT_SAVE 10
45
46#define PERF_TALER_EXCHANGEDB_NB_WITHDRAW_INIT 100
47#define PERF_TALER_EXCHANGEDB_NB_WITHDRAW_SAVE 10
48
49
50/**
51 * Marks the end of the command chain
52 *
53 * @param _label The label of the command
54 */
55#define PERF_TALER_EXCHANGEDB_INIT_CMD_END(_label) \
56 { \
57 .command = PERF_TALER_EXCHANGEDB_CMD_END, \
58 .label = _label, \
59 .exposed.type = PERF_TALER_EXCHANGEDB_NONE \
60 }
61
62
63/**
64 * Prints @ _label to stdout
65 *
66 * @param _label The label of the command,
67 * will be logged each time the command runs
68 */
69#define PERF_TALER_EXCHANGEDB_INIT_CMD_DEBUG(_label) \
70 { \
71 .command = PERF_TALER_EXCHANGEDB_CMD_DEBUG, \
72 .label = _label, \
73 .exposed.type = PERF_TALER_EXCHANGEDB_NONE \
74 }
75
76/**
77 * The begining of a loop
78 *
79 * @param _label the label of the loop
80 * @param _iter the number of iterations of the loop
81 */
82#define PERF_TALER_EXCHANGEDB_INIT_CMD_LOOP(_label, _iter) \
83 { \
84 .command = PERF_TALER_EXCHANGEDB_CMD_LOOP, \
85 .label = _label, \
86 .exposed.type = PERF_TALER_EXCHANGEDB_NONE, \
87 .details.loop = { \
88 .max_iterations = _iter, \
89 .curr_iteration = 0 } \
90 }
91
92/**
93 * Marks the end of the loop @_label_loop
94 *
95 * @param _label the label of the command
96 * @param _label_loop the label of the loop closed by this command
97 */
98#define PERF_TALER_EXCHANGEDB_INIT_CMD_END_LOOP(_label, _label_loop) \
99 { \
100 .command = PERF_TALER_EXCHANGEDB_CMD_END_LOOP, \
101 .label = _label, \
102 .exposed.type = PERF_TALER_EXCHANGEDB_NONE, \
103 .details.end_loop.label_loop = _label_loop \
104 }
105
106/**
107 * Saves the time of execution to use for logging with Gauger
108 *
109 * @param _label the label of the command
110 */
111#define PERF_TALER_EXCHANGEDB_INIT_CMD_GET_TIME(_label) \
112 { \
113 .command = PERF_TALER_EXCHANGEDB_CMD_GET_TIME, \
114 .label = _label, \
115 .exposed.type = PERF_TALER_EXCHANGEDB_TIME \
116 }
117
118/**
119 * Commits the duration between @a _label_start and @a _label_stop
120 * to Gauger with @a _description explaining what was measured.
121 *
122 * @param _label the label of this command
123 * @param _label_start label of the start of the measurment
124 * @param _label_stop label of the end of the measurment
125 * @param _description description of the measure displayed in Gauger
126 * @param _unit the unit of the data measured, typicly something/sec
127 * @param _divide number of measurments in the interval
128 */
129#define PERF_TALER_EXCHANGEDB_INIT_CMD_GAUGER(_label, _label_start, _label_stop, \
130 _category, _description, _unit, \
131 _divide) \
132 { \
133 .command = PERF_TALER_EXCHANGEDB_CMD_GAUGER, \
134 .label = _label, \
135 .exposed.type = PERF_TALER_EXCHANGEDB_NONE, \
136 .details.gauger = { \
137 .label_start = _label_start, \
138 .label_stop = _label_stop, \
139 .category = _category, \
140 .description = _description, \
141 .unit = _unit, \
142 .divide = _divide, \
143 } \
144 }
145
146/**
147 * Initiate a database transaction
148 *
149 * @param _label the label of the command
150 */
151#define PERF_TALER_EXCHANGEDB_INIT_CMD_START_TRANSACTION(_label) \
152 { \
153 .command = PERF_TALER_EXCHANGEDB_CMD_START_TRANSACTION, \
154 .label = _label, \
155 .exposed.type = PERF_TALER_EXCHANGEDB_NONE, \
156 }
157
158/**
159 * Commits a database transaction
160 *
161 * @param _label the label of the command
162 */
163#define PERF_TALER_EXCHANGEDB_INIT_CMD_COMMIT_TRANSACTION(_label) \
164 { \
165 .command = PERF_TALER_EXCHANGEDB_CMD_COMMIT_TRANSACTION, \
166 .label = _label, \
167 .exposed.type = PERF_TALER_EXCHANGEDB_NONE, \
168 }
169
170/**
171 * Abort the current transaction
172 *
173 * @param _label the label of the command
174 */
175#define PERF_TALER_EXCHANGEDB_INIT_CMD_ABORT_TRANSACTION(_label) \
176 { \
177 .command = PERF_TALER_EXCHANGEDB_CMD_ABORT_TRANSACTION, \
178 .label = _label,
179
180/**
181 * Saves randomly selected items from @a _label_save
182 * Saved items can latter be access using #PERF_TALER_EXCHANGEDB_CMD_LOAD_ARRAY
183 *
184 * @param _label the label of the command, used by other commands to reference it
185 * @param _label_loop the label of the loop the array iterates over
186 * @param _label_save the label of the command which outout is saved by this command
187 * @param _nb_saved the total number of items to be saved
188 */
189#define PERF_TALER_EXCHANGEDB_INIT_CMD_SAVE_ARRAY(_label, _label_loop, \
190 _label_save, _nb_saved) \
191 { \
192 .command = PERF_TALER_EXCHANGEDB_CMD_SAVE_ARRAY, \
193 .label = _label, \
194 .exposed.type = PERF_TALER_EXCHANGEDB_NONE, \
195 .details.save_array = { \
196 .label_loop = _label_loop, \
197 .label_save = _label_save, \
198 .nb_saved = _nb_saved, \
199 } \
200 }
201
202/**
203 * Loads data from a #PERF_TALER_EXCHANGEDB_CMD_SAVE_ARRAY to allow other
204 * commands to access it
205 *
206 * @param _label the label of this command, referenced by commands to access it's outpout
207 * @param _label_loop the label of the loop to iterate over
208 * @param _label_save the label of the #PERF_TALER_EXCHANGEDB_CMD_SAVE_ARRAY providing data
209 */
210#define PERF_TALER_EXCHANGEDB_INIT_CMD_LOAD_ARRAY(_label, _label_loop, \
211 _label_save) \
212 { \
213 .command = PERF_TALER_EXCHANGEDB_CMD_LOAD_ARRAY, \
214 .label = _label, \
215 .exposed.type = PERF_TALER_EXCHANGEDB_NONE, \
216 .details.load_array = { \
217 .label_loop = _label_loop, \
218 .label_save = _label_save \
219 } \
220 }
221
222/**
223 * Create a denomination key to use
224 * Exposes a #PERF_TALER_EXCHANGEDB_DENOMINATION_INFO to be used by other commands
225 * @exposed #PERF_TALER_EXCHANGEDB_DENOMINATION_INFO
226 *
227 * @param _label the label of this command
228 */
229#define PERF_TALER_EXCHANGEDB_INIT_CMD_CREATE_DENOMINATION(_label) \
230 { \
231 .command = PERF_TALER_EXCHANGEDB_CMD_CREATE_DENOMINATION, \
232 .label = _label, \
233 .exposed.type = PERF_TALER_EXCHANGEDB_DENOMINATION_INFO, \
234 }
235
236/**
237 * Inserts informations about a denomination key in the database
238 *
239 * @param _label the label of this command
240 * @param _label_denom the label of the denomination to insert
241 */
242#define PERF_TALER_EXCHANGEDB_INIT_CMD_INSERT_DENOMINATION(_label, _label_denom) \
243 { \
244 .command = PERF_TALER_EXCHANGEDB_CMD_INSERT_DENOMINATION, \
245 .label = _label, \
246 .exposed.type = PERF_TALER_EXCHANGEDB_NONE, \
247 .details.insert_denomination.label_denom = _label_denom, \
248 }
249
250/**
251 * Polls the database about informations regarding a specific denomination key
252 *
253 * @param _label the label of this command
254 * @param _label_denom the label of the command providing information about the denomination key
255 */
256#define PERF_TALER_EXCHANGEDB_INIT_CMD_GET_DENOMINATION(_label, _label_denom) \
257 { \
258 .command = PERF_TALER_EXCHANGEDB_CMD_GET_DENOMINATION, \
259 .label = _label, \
260 .exposed.type = PERF_TALER_EXCHANGEDB_NONE, \
261 .details.get_denomination.label_denom = _label_denom \
262 }
263
264/**
265 * Create a reserve to be used later
266 * Exposes a #PERF_TALER_EXCHANGEDB_RESERVE
267 *
268 * @param _label the label of the command
269 */
270#define PERF_TALER_EXCHANGEDB_INIT_CMD_CREATE_RESERVE(_label) \
271 { \
272 .command = PERF_TALER_EXCHANGEDB_CMD_CREATE_RESERVE, \
273 .label = _label, \
274 .exposed.type = PERF_TALER_EXCHANGEDB_RESERVE \
275 }
276
277/**
278 * Insert a new reserve in the database containing 1000 Euros
279 *
280 * @param _label the name of this command
281 * @param _label_reserve the label of the reserve to insert
282 */
283#define PERF_TALER_EXCHANGEDB_INIT_CMD_INSERT_RESERVE(_label, _label_reserve) \
284 { \
285 .command = PERF_TALER_EXCHANGEDB_CMD_INSERT_RESERVE, \
286 .label = _label, \
287 .exposed.type = PERF_TALER_EXCHANGEDB_NONE, \
288 .details.insert_reserve.label_reserve = _label_reserve \
289 }
290
291/**
292 * Polls the database for a secific reserve's details
293 *
294 * @param _label the label of this command
295 * @param _label_reserve the reserve to poll
296 */
297#define PERF_TALER_EXCHANGEDB_INIT_CMD_GET_RESERVE(_label, _label_reserve) \
298 { \
299 .command = PERF_TALER_EXCHANGEDB_CMD_GET_RESERVE, \
300 .label = _label, \
301 .exposed.type = PERF_TALER_EXCHANGEDB_NONE, \
302 .details.get_reserve.label_reserve = _label_reserve \
303 }
304
305/**
306 * Polls the database for the history of a reserve
307 *
308 * @param _label the label of the command
309 * @param _label_reserve the reserve to examine
310 */
311#define PERF_TALER_EXCHANGEDB_INIT_CMD_GET_RESERVE_HISTORY(_label, \
312 _label_reserve) \
313 { \
314 .command = PERF_TALER_EXCHANGEDB_CMD_GET_RESERVE_HISTORY, \
315 .label = _label, \
316 .exposed.type = PERF_TALER_EXCHANGEDB_NONE, \
317 .details.get_reserve_history.label_reserve = _label_reserve \
318 }
319
320/**
321 * Creates a coin to be used later
322 *
323 * @param _label the label of this command
324 * @param _label_dki denomination key used to sign the coin
325 * @param _label_reserve reserve used to emmit the coin
326 */
327#define PERF_TALER_EXCHANGEDB_INIT_CMD_CREATE_WITHDRAW(_label, _label_dki, \
328 _label_reserve) \
329 { \
330 .command = PERF_TALER_EXCHANGEDB_CMD_CREATE_WITHDRAW, \
331 .label = _label, \
332 .exposed.type = PERF_TALER_EXCHANGEDB_COIN, \
333 .details.create_withdraw = { \
334 .label_dki = _label_dki, \
335 .label_reserve = _label_reserve, \
336 } \
337 }
338
339/**
340 * Inserts information about a withdrawal into the database
341 *
342 * @exposes #PERF_TALER_EXCHANGEDB_COIN
343 *
344 * @param _label the label of this command
345 * @param _label_coin the coin to insert
346 */
347#define PERF_TALER_EXCHANGEDB_INIT_CMD_INSERT_WITHDRAW(_label, _label_coin) \
348 { \
349 .command = PERF_TALER_EXCHANGEDB_CMD_INSERT_WITHDRAW, \
350 .label = _label, \
351 .exposed.type = PERF_TALER_EXCHANGEDB_NONE, \
352 .details.insert_withdraw.label_coin = _label_coin \
353 }
354
355
356/**
357 * Polls the database about informations regarding a specific withdrawal
358 *
359 * @param _label the label of this command
360 * @param _label_coin the coin to check
361 */
362#define PERF_TALER_EXCHANGEDB_INIT_CMD_GET_WITHDRAW(_label, _label_coin) \
363 { \
364 .command = PERF_TALER_EXCHANGEDB_CMD_GET_WITHDRAW, \
365 .label = _label, \
366 .exposed.type = PERF_TALER_EXCHANGEDB_NONE, \
367 .details.get_withdraw.label_coin = _label_coin, \
368 }
369
370
371/**
372 * The /reserve/withdraw api call
373 *
374 * Exposes #PERF_TALER_EXCHANGEDB_COIN
375 *
376 * @param _label the label of this command
377 * @param _label_dki the denomination of the created coin
378 * @param _label_reserve the reserve used to provide currency
379 */
380#define PERF_TALER_EXCHANGEDB_INIT_CMD_WITHDRAW_SIGN(_label, _label_dki, \
381 _label_reserve) \
382 PERF_TALER_EXCHANGEDB_INIT_CMD_CREATE_WITHDRAW (_label "withdraw", \
383 _label_dki, \
384 _label_reserve), \
385 PERF_TALER_EXCHANGEDB_INIT_CMD_GET_DENOMINATION (_label "withdraw info", \
386 _label_dki), \
387 PERF_TALER_EXCHANGEDB_INIT_CMD_GET_RESERVE_HISTORY (_label "reserve_history", \
388 _label_reserve), \
389 PERF_TALER_EXCHANGEDB_INIT_CMD_INSERT_WITHDRAW (_label "insert withdraw", \
390 _label "withdraw")
391
392/**
393 * Create a deposit for use later
394 * @exposes #PERF_TALER_EXCHANGEDB_DEPOSIT
395 *
396 * @param _label the label of this command
397 * @param _label_coin the coin used to pay
398 */
399#define PERF_TALER_EXCHANGEDB_INIT_CMD_CREATE_DEPOSIT(_label, _label_coin) \
400 { \
401 .command = PERF_TALER_EXCHANGEDB_CMD_CREATE_DEPOSIT, \
402 .label = _label, \
403 .exposed.type = PERF_TALER_EXCHANGEDB_DEPOSIT, \
404 .details.create_deposit.label_coin = _label_coin, \
405 }
406
407/**
408 * Insert a deposit into the database
409 *
410 * @param _label the label of this command
411 * @param _label_deposit the deposit inseerted
412 */
413#define PERF_TALER_EXCHANGEDB_INIT_CMD_INSERT_DEPOSIT(_label, _label_deposit) \
414 { \
415 .command = PERF_TALER_EXCHANGEDB_CMD_INSERT_DEPOSIT, \
416 .label = _label, \
417 .exposed.type = PERF_TALER_EXCHANGEDB_NONE, \
418 .details.insert_deposit.label_deposit = _label_deposit, \
419 }
420
421/**
422 * Check if a deposit is in the database
423 *
424 * @param _label the label of this command
425 * @param _label_deposit the deposit to use
426 */
427#define PERF_TALER_EXCHANGEDB_INIT_CMD_GET_DEPOSIT(_label, _label_deposit) \
428 { \
429 .command = PERF_TALER_EXCHANGEDB_CMD_GET_DEPOSIT, \
430 .label = _label, \
431 .exposed.type = PERF_TALER_EXCHANGEDB_NONE, \
432 .details.get_deposit.label_deposit = _label_deposit \
433 }
434
435/**
436 * Access the transaction history of a coin
437 *
438 * @param _label the label of the command
439 * @param _label_coin the coin which history is checked
440 */
441#define PERF_TALER_EXCHANGEDB_INIT_CMD_GET_COIN_TRANSACTION(_label, _label_coin) \
442 { \
443 .command = PERF_TALER_EXCHANGEDB_CMD_GET_COIN_TRANSACTION, \
444 .label = _label, \
445 .exposed.type = PERF_TALER_EXCHANGEDB_NONE, \
446 .details.get_coin_transaction.label_coin = _label_coin \
447 }
448
449/**
450 * The /deposit api call
451 *
452 * @param _label the label of the command
453 * @param _label_coin the coin used for the deposit
454 */
455#define PERF_TALER_EXCHANGEDB_INIT_CMD_DEPOSIT(_label, _label_coin) \
456 PERF_TALER_EXCHANGEDB_INIT_CMD_GET_COIN_TRANSACTION (_label "coin history", \
457 _label_coin), \
458 PERF_TALER_EXCHANGEDB_INIT_CMD_CREATE_DEPOSIT (_label "deposit", \
459 _label_coin), \
460 PERF_TALER_EXCHANGEDB_INIT_CMD_INSERT_DEPOSIT (_label "insert", \
461 _label "deposit")
462
463/**
464 * Insert informations about a refresh session
465 * melts one coin into another
466 *
467 * @param _label the label of the command
468 */
469#define PERF_TALER_EXCHANGEDB_INIT_CMD_CREATE_REFRESH_SESSION(_label, \
470 _label_coin) \
471 { \
472 .command = PERF_TALER_EXCHANGEDB_CMD_CREATE_REFRESH_SESSION, \
473 .label = _label, \
474 .details.create_refresh_session.label_coin = _label_coin, \
475 .exposed.type = PERF_TALER_EXCHANGEDB_REFRESH_HASH \
476 }
477
478/**
479 * Get informations about a refresh session
480 *
481 * @param _label the label of the command
482 * @param _label_hash the label of the hash to search
483 */
484#define PERF_TALER_EXCHANGEDB_INIT_CMD_GET_REFRESH_SESSION(_label, \
485 _label_hash) \
486 { \
487 .command = PERF_TALER_EXCHANGEDB_CMD_GET_REFRESH_SESSION, \
488 .label = _label, \
489 .exposed.type = PERF_TALER_EXCHANGEDB_NONE \
490 }
491
492
493/**
494 * The type of data stored in #PERF_TALER_EXCHANGEDB_Memory
495 */
496enum PERF_TALER_EXCHANGEDB_Type
497{
498 PERF_TALER_EXCHANGEDB_NONE,
499 PERF_TALER_EXCHANGEDB_TIME,
500 PERF_TALER_EXCHANGEDB_DENOMINATION_INFO,
501 PERF_TALER_EXCHANGEDB_RESERVE,
502 PERF_TALER_EXCHANGEDB_COIN,
503 PERF_TALER_EXCHANGEDB_DEPOSIT,
504 PERF_TALER_EXCHANGEDB_REFRESH_HASH
505};
506
507
508/**
509 * Structure used to handle several data type
510 */
511struct PERF_TALER_EXCHANGEDB_Data
512{
513 enum PERF_TALER_EXCHANGEDB_Type type;
514
515 /**
516 * Storage for a variety of data type
517 * The data saved should match #type
518 */
519 union PERF_TALER_EXCHANGEDB_Memory
520 {
521 /** #PERF_TALER_EXCHANGEDB_TIME */
522 struct GNUNET_TIME_Absolute *time;
523 /** #PERF_TALER_EXCHANGEDB_DEPOSIT */
524 struct TALER_EXCHANGEDB_Deposit *deposit;
525 /** #PERF_TALER_EXCHANGEDB_COIN */
526 struct PERF_TALER_EXCHANGEDB_Coin *coin;
527 /** #PERF_TALER_EXCHANGEDB_RESERVE */
528 struct PERF_TALER_EXCHANGEDB_Reserve *reserve;
529 /** #PERF_TALER_EXCHANGEDB_DENOMINATION_INFO */
530 struct TALER_EXCHANGEDB_DenominationKeyIssueInformation *dki;
531 /** #PERF_TALER_EXCHANGEDB_REFRESH_HASH */
532 struct TALER_RefreshCommitmentP rc;
533 } data;
534};
535
536
537/**
538 * Name of the command
539 */
540enum PERF_TALER_EXCHANGEDB_CMD_Name
541{
542 /**
543 * All comand chain must hace this as their last command
544 */
545 PERF_TALER_EXCHANGEDB_CMD_END,
546
547 /**
548 * Prints it's label
549 */
550 PERF_TALER_EXCHANGEDB_CMD_DEBUG,
551
552 /**
553 * Define the start of al command chain loop
554 */
555 PERF_TALER_EXCHANGEDB_CMD_LOOP,
556
557 /**
558 * Define the end of a command chain loop
559 */
560 PERF_TALER_EXCHANGEDB_CMD_END_LOOP,
561
562 /**
563 * Save the time at which the command was executed
564 */
565 PERF_TALER_EXCHANGEDB_CMD_GET_TIME,
566
567 /**
568 * Upload performance to Gauger
569 */
570 PERF_TALER_EXCHANGEDB_CMD_GAUGER,
571
572 /**
573 * Start a new session
574 */
575 PERF_TALER_EXCHANGEDB_CMD_NEW_SESSION,
576
577 /**
578 * Start a database transaction
579 */
580 PERF_TALER_EXCHANGEDB_CMD_START_TRANSACTION,
581
582 /**
583 * End a database transaction
584 */
585 PERF_TALER_EXCHANGEDB_CMD_COMMIT_TRANSACTION,
586
587 /**
588 * Abort a transaction started with #PERF_TALER_EXCHANGEDB_CMD_START_TRANSACTION
589 */
590 PERF_TALER_EXCHANGEDB_CMD_ABORT_TRANSACTION,
591
592 /**
593 * Saves random deposits from a loop
594 */
595 PERF_TALER_EXCHANGEDB_CMD_SAVE_ARRAY,
596
597 /**
598 * Load items saved earlier in a #PERF_TALER_EXCHANGEDB_CMD_SAVE_ARRAY
599 * The items are loaded in a random order, but all of them will be loaded
600 */
601 PERF_TALER_EXCHANGEDB_CMD_LOAD_ARRAY,
602
603 /**
604 * Loads a random item from a #PERF_TALER_EXCHANGEDB_CMD_SAVE_ARRAY
605 * A random item is loaded each time the command is run
606 */
607 PERF_TALER_EXCHANGEDB_CMD_LOAD_RANDOM,
608
609 /**
610 * Create a denomination to be used later
611 */
612 PERF_TALER_EXCHANGEDB_CMD_CREATE_DENOMINATION,
613
614 /**
615 * Insert informations about a denomination key in the database
616 */
617 PERF_TALER_EXCHANGEDB_CMD_INSERT_DENOMINATION,
618
619 /**
620 * Polls the database for informations about a specific denomination key
621 */
622 PERF_TALER_EXCHANGEDB_CMD_GET_DENOMINATION,
623
624 /**
625 * Create a reserve to be used later
626 */
627 PERF_TALER_EXCHANGEDB_CMD_CREATE_RESERVE,
628
629 /**
630 * Insert currency in a reserve / Create a reserve
631 */
632 PERF_TALER_EXCHANGEDB_CMD_INSERT_RESERVE,
633
634 /**
635 * Get Informations about a reserve
636 */
637 PERF_TALER_EXCHANGEDB_CMD_GET_RESERVE,
638
639 /**
640 * Get the history of a reserve
641 */
642 PERF_TALER_EXCHANGEDB_CMD_GET_RESERVE_HISTORY,
643
644 /**
645 * Create a withdrawal to be used later
646 */
647 PERF_TALER_EXCHANGEDB_CMD_CREATE_WITHDRAW,
648
649 /**
650 * Insert informations about a withdrawal in the database
651 */
652 PERF_TALER_EXCHANGEDB_CMD_INSERT_WITHDRAW,
653
654 /**
655 * Pulls informations about a withdrawal from the database
656 */
657 PERF_TALER_EXCHANGEDB_CMD_GET_WITHDRAW,
658
659 /**
660 * Get the list of all transactions the coin has been in
661 */
662 PERF_TALER_EXCHANGEDB_CMD_GET_COIN_TRANSACTION,
663
664 /**
665 * Create a deposit to be used later
666 */
667 PERF_TALER_EXCHANGEDB_CMD_CREATE_DEPOSIT,
668
669 /**
670 * Insert a deposit into the database
671 */
672 PERF_TALER_EXCHANGEDB_CMD_INSERT_DEPOSIT,
673
674 /**
675 * Check if a deposit is in the database
676 */
677 PERF_TALER_EXCHANGEDB_CMD_GET_DEPOSIT,
678
679 /**
680 * Create a refresh session
681 * The number of melted coins is 1,
682 * The number of exchangeed coins is 1
683 */
684 PERF_TALER_EXCHANGEDB_CMD_CREATE_REFRESH_SESSION,
685
686 /**
687 * Get a refresh session informations
688 */
689 PERF_TALER_EXCHANGEDB_CMD_GET_REFRESH_SESSION,
690
691 /**
692 * Insert a melt refresh reveal data
693 */
694 PERF_TALER_EXCHANGEDB_CMD_INSERT_REFRESH_REVEAL,
695
696 /**
697 * Get informations about a refresh reveal data
698 */
699 PERF_TALER_EXCHANGEDB_CMD_GET_REFRESH_REVEAL,
700
701 /**
702 * Get the link data list of a coin
703 */
704 PERF_TALER_EXCHANGEDB_CMD_GET_LINK_DATA
705
706};
707
708
709/**
710 * Contains extra data required for any command
711 */
712union PERF_TALER_EXCHANGEDB_CMD_Details
713{
714 /**
715 * Extra data requiered for the #PERF_TALER_EXCHANGEDB_CMD_LOOP command
716 */
717 struct PERF_TALER_EXCHANGEDB_CMD_loopDetails
718 {
719 /**
720 * Maximum number of iteration in the loop
721 */
722 const unsigned int max_iterations;
723
724 /**
725 * The current iteration of the loop
726 */
727 unsigned int curr_iteration;
728 } loop;
729
730 /**
731 * Extra data requiered by the #PERF_TALER_EXCHANGEDB_CMD_END_LOOP command
732 */
733 struct PERF_TALER_EXCHANGEDB_CMD_endLoopDetails
734 {
735 /**
736 * Label of the loop closed by the command
737 */
738 const char *label_loop;
739 unsigned int index_loop;
740 } end_loop;
741
742 /**
743 * Details about the #PERF_TALER_EXCHANGEDB_CMD_GAUGER command
744 */
745 struct PERF_TALER_EXCHANGEDB_CMD_gaugerDetails
746 {
747 /**
748 * Label of the starting timestamp
749 */
750 const char *label_start;
751 unsigned int index_start;
752
753 /**
754 * Label of the ending timestamp
755 */
756 const char *label_stop;
757 unsigned int index_stop;
758
759 /**
760 * The category of the measurment
761 */
762 const char *category;
763
764 /**
765 * Description of the metric, used in Gauger
766 */
767 const char *description;
768
769 /**
770 * The name of the metric beeing used
771 */
772 const char *unit;
773
774 /**
775 * Constant the result needs to be divided by
776 * to get the result per unit
777 */
778 float divide;
779 } gauger;
780
781 /**
782 * Contains extra data requiered by the #PERF_TALER_EXCHANGEDB_CMD_SAVE_ARRAY command
783 */
784 struct PERF_TALER_EXCHANGEDB_CMD_saveArrayDetails
785 {
786 /**
787 * Number of items to save
788 */
789 unsigned int nb_saved;
790
791 /**
792 * Number of items already saved
793 */
794 unsigned int index;
795
796 /**
797 * Label of the loop it is attached to
798 */
799 const char *label_loop;
800 unsigned int index_loop;
801
802 /**
803 * Label of the command exposing the item
804 */
805 const char *label_save;
806 unsigned int index_save;
807
808 /**
809 * Array of data saved
810 */
811 struct PERF_TALER_EXCHANGEDB_Data *data_saved;
812
813 /**
814 * Type of the data that will be stored in @a data_saved, for
815 * 'static' type checking.
816 */
817 enum PERF_TALER_EXCHANGEDB_Type type_saved;
818
819 } save_array;
820
821 /**
822 * Extra data required for the #PERF_TALER_EXCHANGEDB_CMD_LOAD_ARRAY command
823 */
824 struct PERF_TALER_EXCHANGEDB_CMD_loadArrayDetails
825 {
826 /**
827 * The loop in which the command is located
828 */
829 const char *label_loop;
830 unsigned int index_loop;
831
832 /**
833 * Label of the command where the items were saved
834 */
835 const char *label_save;
836 unsigned int index_save;
837
838 /**
839 * A permutation array used to randomize the order the items are loaded in
840 */
841 unsigned int *permutation;
842 } load_array;
843
844 /**
845 * Contains data for the #PERF_TALER_EXCHANGEDB_CMD_LOAD_RANDOM command
846 */
847 struct PERF_TALER_EXCHANGEDB_CMD_loadRandomDetails
848 {
849 /**
850 * The label of the #PERF_TALER_EXCHANGEDB_CMD_SAVE_ARRAY the items will be extracted from
851 */
852 const char *label_save;
853 unsigned int index_save;
854 } load_random;
855
856 /**
857 * Extra data requiered by the #PERF_TALER_EXCHANGEDB_CMD_INSERT_DENOMINATION command
858 */
859 struct PERF_TALER_EXCHANGEDB_CMD_insertDenominationDetails
860 {
861 /**
862 * The label of the source of the denomination to insert
863 */
864 const char *label_denom;
865 unsigned int index_denom;
866 } insert_denomination;
867
868 /**
869 * Extra data requiered by the #PERF_TALER_EXCHANGEDB_CMD_GET_DENOMINATION command
870 */
871 struct PERF_TALER_EXCHANGEDB_CMD_getDenominationDetails
872 {
873 /**
874 * The label of the source of the denomination to check
875 */
876 const char *label_denom;
877 unsigned int index_denom;
878 } get_denomination;
879
880 /**
881 * Extra data requiered for the #PERF_TALER_EXCHANGEDB_CMD_INSERT_RESERVE command
882 */
883 struct PERF_TALER_EXCHANGEDB_CMD_insertReserveDetails
884 {
885 /**
886 * The label of the source of the reserve to insert
887 */
888 const char *label_reserve;
889 unsigned int index_reserve;
890 } insert_reserve;
891
892 /**
893 * Extra data requiered for the #PERF_TALER_EXCHANGEDB_CMD_GET_RESERVE command
894 */
895 struct PERF_TALER_EXCHANGEDB_CMD_getReserveDetails
896 {
897 /**
898 * The label of the source of the reserve to check
899 */
900 const char *label_reserve;
901 unsigned int index_reserve;
902 } get_reserve;
903
904 /**
905 * Extra data requiered for the #PERF_TALER_EXCHANGEDB_CMD_GET_RESERVE_HISTORY command
906 */
907 struct PERF_TALER_EXCHANGEDB_CMD_getReserveHistoryDetails
908 {
909 /**
910 * The label of the source of the reserve to check
911 */
912 const char *label_reserve;
913 unsigned int index_reserve;
914 } get_reserve_history;
915
916 /**
917 * Extra data related to the #PERF_TALER_EXCHANGEDB_CMD_CREATE_WITHDRAW command
918 */
919 struct PERF_TALER_EXCHANGEDB_CMD_createWithdrawDetails
920 {
921 /**
922 * label of the denomination key used to sign the coin
923 */
924 const char *label_dki;
925 unsigned int index_dki;
926
927 /**
928 * label of the reserve the money to exchange the coin comes from
929 */
930 const char *label_reserve;
931 unsigned int index_reserve;
932 } create_withdraw;
933
934 /**
935 * data requiered for the #PERF_TALER_EXCHANGEDB_CMD_INSERT_WITHDRAW
936 */
937 struct PERF_TALER_EXCHANGEDB_CMD_insertWithdrawDetails
938 {
939 /**
940 * label of the source for the coin information
941 */
942 const char *label_coin;
943 unsigned int index_coin;
944 } insert_withdraw;
945
946 /**
947 * data requiered for the #PERF_TALER_EXCHANGEDB_CMD_GET_WITHDRAW
948 */
949 struct PERF_TALER_EXCHANGEDB_CMD_getWithdraw
950 {
951 /**
952 * label of the source for the coin information
953 */
954 const char *label_coin;
955 unsigned int index_coin;
956 } get_withdraw;
957
958 /**
959 * Data requiered for the #PERF_TALER_EXCHANGEDB_CMD_GET_COIN_TRANSACTION command
960 */
961 struct PERF_TALER_EXCHANGEDB_CMD_getCoinTransactionDetails
962 {
963 /**
964 * The coin which history is checked
965 */
966 const char *label_coin;
967 unsigned int index_coin;
968 } get_coin_transaction;
969
970 /**
971 * Data used by the #PERF_TALER_EXCHANGEDB_CMD_CREATE_DEPOSIT command
972 */
973 struct PERF_TALER_EXCHANGEDB_CMD_createDepositDetails
974 {
975 /**
976 * Label of the source where the reserve used to create the coin is
977 */
978 const char *label_coin;
979 unsigned int index_coin;
980 } create_deposit;
981
982 /**
983 * Extra data requiered for the #PERF_TALER_EXCHANGEDB_CMD_INSERT_DEPOSIT command
984 */
985 struct PERF_TALER_EXCHANGEDB_CMD_insertDepositDetails
986 {
987 /**
988 * The label of the source of the deposit to check
989 */
990 const char *label_deposit;
991 unsigned int index_deposit;
992 } insert_deposit;
993
994 /**
995 * Extra data requiered for the #PERF_TALER_EXCHANGEDB_CMD_GET_DEPOSIT command
996 */
997 struct PERF_TALER_EXCHANGEDB_CMD_getDepositDetails
998 {
999 /**
1000 * The label of the source of the deposit to check
1001 */
1002 const char *label_deposit;
1003 unsigned int index_deposit;
1004 } get_deposit;
1005
1006 /**
1007 * Data requiered for the #PERF_TALER_EXCHANGEDB_CMD_CREATE_REFRESH_SESSION command
1008 */
1009 struct PERF_TALER_EXCHANGEDB_CMD_createRefreshSessionDetails
1010 {
1011 /**
1012 * label of the source of the hash of the session
1013 */
1014 const char *label_coin;
1015 unsigned int index_coin;
1016 } create_refresh_session;
1017
1018 /**
1019 * Data requiered for the #PERF_TALER_EXCHANGEDB_CMD_GET_REFRESH_SESSION command
1020 */
1021 struct PERF_TALER_EXCHANGEDB_CMD_getRefreshSessionDetails
1022 {
1023 /**
1024 * label of the source of the hash of the session
1025 */
1026 const char *label_hash;
1027 unsigned int index_hash;
1028 } get_refresh_session;
1029
1030 /**
1031 * Data requiered for the #PERF_TALER_EXCHANGEDB_CMD_INSERT_REFRESH_REVEAL command
1032 */
1033 struct PERF_TALER_EXCHANGEDB_CMD_insertRefreshRevealDetails
1034 {
1035 /**
1036 * The refresh session hash
1037 */
1038 const char *label_hash;
1039 unsigned int index_hash;
1040
1041 /**
1042 * The new coin denomination
1043 */
1044 const char *label_denom;
1045 unsigned int index_denom;
1046 } insert_refresh_reveal;
1047
1048 /**
1049 * Data requiered for the #PERF_TALER_EXCHANGEDB_CMD_GET_REFRESH_REVEAL command
1050 */
1051 struct PERF_TALER_EXCHANGEDB_CMD_getRefreshRevealDetails
1052 {
1053 /**
1054 * The session hash
1055 */
1056 const char *label_hash;
1057 unsigned int index_hash;
1058
1059 } get_refresh_reveal;
1060
1061 /**
1062 * Data requiered by the #PERF_TALER_EXCHANGEDB_CMD_GET_LINK_DATA_LIST command
1063 */
1064 struct PERF_TALER_EXCHANGEDB_CMD_getLinkDataListDetails
1065 {
1066 /**
1067 * The refresh session hash
1068 */
1069 const char *label_hash;
1070 unsigned int index_hash;
1071 } get_link_data_list;
1072
1073
1074};
1075
1076
1077/**
1078 * Command to be interpreted.
1079 */
1080struct PERF_TALER_EXCHANGEDB_Cmd
1081{
1082 /**
1083 * Type of the command
1084 */
1085 enum PERF_TALER_EXCHANGEDB_CMD_Name command;
1086
1087 /**
1088 * Label to refer to the command
1089 */
1090 const char *label;
1091
1092 /**
1093 * Command specific data
1094 */
1095 union PERF_TALER_EXCHANGEDB_CMD_Details details;
1096
1097 /**
1098 * Data easily accessible
1099 */
1100 struct PERF_TALER_EXCHANGEDB_Data exposed;
1101};
1102
1103
1104/**
1105 * Run a benchmark
1106 *
1107 * @param benchmark_name the name of the benchmark, displayed in the logs
1108 * @param configuration_file path to the taler configuration file to use
1109 * @param init the commands to use for the database initialisation,
1110 * if #NULL the standard initialization is used
1111 * @param benchmark the commands for the benchmark
1112 * @return #GNUNET_OK upon success; #GNUNET_SYSERR upon failure,
1113 * #GNUNET_NO if we failed to init the database
1114 */
1115int
1116PERF_TALER_EXCHANGEDB_run_benchmark (const char *benchmark_name,
1117 const char *configuration_file,
1118 struct PERF_TALER_EXCHANGEDB_Cmd *init,
1119 struct PERF_TALER_EXCHANGEDB_Cmd *benchmark);
1120
1121
1122/**
1123 * Runs the command array @a cmd
1124 * using @a db_plugin to connect to the database
1125 *
1126 * @param db_plugin the connection to the database
1127 * @param cmd the commands to run
1128 */
1129int
1130PERF_TALER_EXCHANGEDB_interpret (struct TALER_EXCHANGEDB_Plugin *db_plugin,
1131 struct PERF_TALER_EXCHANGEDB_Cmd cmd[]);
1132
1133
1134/**
1135 * Check if the given command array is syntaxicly correct
1136 * This will check if the label are corrects but will not check if
1137 * they are pointing to an apropriate command.
1138 *
1139 * @param cmd the command array to check
1140 * @return #GNUNET_OK is @a cmd is correct; #GNUNET_SYSERR if it is'nt
1141 */
1142int
1143PERF_TALER_EXCHANGEDB_check (const struct PERF_TALER_EXCHANGEDB_Cmd *cmd);
1144
1145#endif