diff options
Diffstat (limited to 'src/exchangedb/test_perf_taler_exchangedb.c')
-rw-r--r-- | src/exchangedb/test_perf_taler_exchangedb.c | 188 |
1 files changed, 0 insertions, 188 deletions
diff --git a/src/exchangedb/test_perf_taler_exchangedb.c b/src/exchangedb/test_perf_taler_exchangedb.c deleted file mode 100644 index ad8e630d4..000000000 --- a/src/exchangedb/test_perf_taler_exchangedb.c +++ /dev/null | |||
@@ -1,188 +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/test_perf_taler_exchangedb.c | ||
18 | * @brief Exchange database performance analysis | ||
19 | * @author Nicolas Fournier | ||
20 | */ | ||
21 | #include "platform.h" | ||
22 | #include "perf_taler_exchangedb_interpreter.h" | ||
23 | #include "perf_taler_exchangedb_init.h" | ||
24 | |||
25 | |||
26 | #define NB_DENOMINATION_INIT 2 | ||
27 | #define NB_DENOMINATION_SAVE 2 | ||
28 | |||
29 | #define NB_RESERVE_INIT 4 | ||
30 | #define NB_RESERVE_SAVE 1 | ||
31 | |||
32 | #define NB_DEPOSIT_INIT 1 | ||
33 | #define NB_DEPOSIT_SAVE 1 | ||
34 | |||
35 | #define NB_WITHDRAW_INIT 1 | ||
36 | #define NB_WITHDRAW_SAVE 1 | ||
37 | |||
38 | |||
39 | /** | ||
40 | * Allocate, copies and free all the data used in the interpreter | ||
41 | * Used to check for memory leaks | ||
42 | */ | ||
43 | static void | ||
44 | test_allocate () | ||
45 | { | ||
46 | struct TALER_EXCHANGEDB_DenominationKeyIssueInformation *dki; | ||
47 | struct TALER_EXCHANGEDB_DenominationKeyIssueInformation *dki_copy; | ||
48 | struct PERF_TALER_EXCHANGEDB_Reserve *reserve, *reserve_copy; | ||
49 | struct PERF_TALER_EXCHANGEDB_Coin *coin, *coin_copy; | ||
50 | struct TALER_EXCHANGEDB_Deposit *deposit, *deposit_copy; | ||
51 | |||
52 | dki = PERF_TALER_EXCHANGEDB_denomination_init (); | ||
53 | reserve = PERF_TALER_EXCHANGEDB_reserve_init (); | ||
54 | coin = PERF_TALER_EXCHANGEDB_coin_init (dki, | ||
55 | reserve); | ||
56 | deposit = PERF_TALER_EXCHANGEDB_deposit_init (coin); | ||
57 | |||
58 | dki_copy = PERF_TALER_EXCHANGEDB_denomination_copy (dki); | ||
59 | reserve_copy = PERF_TALER_EXCHANGEDB_reserve_copy (reserve); | ||
60 | coin_copy = PERF_TALER_EXCHANGEDB_coin_copy (coin); | ||
61 | deposit_copy = PERF_TALER_EXCHANGEDB_deposit_copy (deposit); | ||
62 | |||
63 | PERF_TALER_EXCHANGEDB_denomination_free (dki); | ||
64 | PERF_TALER_EXCHANGEDB_denomination_free (dki_copy); | ||
65 | PERF_TALER_EXCHANGEDB_reserve_free (reserve); | ||
66 | PERF_TALER_EXCHANGEDB_reserve_free (reserve_copy); | ||
67 | PERF_TALER_EXCHANGEDB_coin_free (coin); | ||
68 | PERF_TALER_EXCHANGEDB_coin_free (coin_copy); | ||
69 | PERF_TALER_EXCHANGEDB_deposit_free (deposit); | ||
70 | PERF_TALER_EXCHANGEDB_deposit_free (deposit_copy); | ||
71 | } | ||
72 | |||
73 | |||
74 | /** | ||
75 | * Runs the performances tests for the exchange database | ||
76 | * and logs the results using Gauger | ||
77 | */ | ||
78 | int | ||
79 | main (int argc, char **argv) | ||
80 | { | ||
81 | int ret = 0; | ||
82 | struct PERF_TALER_EXCHANGEDB_Cmd init[] = { | ||
83 | PERF_TALER_EXCHANGEDB_INIT_CMD_END ("init") | ||
84 | }; | ||
85 | struct PERF_TALER_EXCHANGEDB_Cmd benchmark[] = { | ||
86 | // Denomination used to create coins | ||
87 | PERF_TALER_EXCHANGEDB_INIT_CMD_DEBUG ("00 - Start of interpreter"), | ||
88 | |||
89 | PERF_TALER_EXCHANGEDB_INIT_CMD_LOOP ("01 - denomination loop", | ||
90 | NB_DENOMINATION_INIT), | ||
91 | PERF_TALER_EXCHANGEDB_INIT_CMD_START_TRANSACTION ("01 - start transaction"), | ||
92 | PERF_TALER_EXCHANGEDB_INIT_CMD_CREATE_DENOMINATION ("01 - denomination"), | ||
93 | PERF_TALER_EXCHANGEDB_INIT_CMD_INSERT_DENOMINATION ("01 - insert", | ||
94 | "01 - denomination"), | ||
95 | PERF_TALER_EXCHANGEDB_INIT_CMD_COMMIT_TRANSACTION ( | ||
96 | "01 - commit transaction"), | ||
97 | PERF_TALER_EXCHANGEDB_INIT_CMD_SAVE_ARRAY ("01 - save denomination", | ||
98 | "01 - denomination loop", | ||
99 | "01 - denomination", | ||
100 | NB_DENOMINATION_SAVE), | ||
101 | PERF_TALER_EXCHANGEDB_INIT_CMD_END_LOOP ("01 - denomination loop end", | ||
102 | "01 - denomination loop"), | ||
103 | PERF_TALER_EXCHANGEDB_INIT_CMD_DEBUG ("01 - init denomination complete"), | ||
104 | // End of initialization | ||
105 | // Reserve initialization | ||
106 | PERF_TALER_EXCHANGEDB_INIT_CMD_LOOP ("02 - init reserve loop", | ||
107 | NB_RESERVE_INIT), | ||
108 | |||
109 | PERF_TALER_EXCHANGEDB_INIT_CMD_CREATE_RESERVE ("02 - reserve"), | ||
110 | PERF_TALER_EXCHANGEDB_INIT_CMD_INSERT_RESERVE ("02 - insert", | ||
111 | "02 - reserve"), | ||
112 | PERF_TALER_EXCHANGEDB_INIT_CMD_SAVE_ARRAY ("02 - save reserve", | ||
113 | "02 - init reserve loop", | ||
114 | "02 - reserve", | ||
115 | NB_RESERVE_SAVE), | ||
116 | PERF_TALER_EXCHANGEDB_INIT_CMD_END_LOOP ("02 - init reserve end loop", | ||
117 | "02 - init reserve loop"), | ||
118 | PERF_TALER_EXCHANGEDB_INIT_CMD_DEBUG ("02 - reserve init complete"), | ||
119 | // End reserve init | ||
120 | // Withdrawal initialization | ||
121 | PERF_TALER_EXCHANGEDB_INIT_CMD_LOOP ("03 - init withdraw loop", | ||
122 | NB_WITHDRAW_INIT), | ||
123 | PERF_TALER_EXCHANGEDB_INIT_CMD_START_TRANSACTION ("03 - start transaction"), | ||
124 | PERF_TALER_EXCHANGEDB_INIT_CMD_LOAD_ARRAY ("03 - denomination load", | ||
125 | "03 - init withdraw loop", | ||
126 | "01 - save denomination"), | ||
127 | PERF_TALER_EXCHANGEDB_INIT_CMD_LOAD_ARRAY ("03 - reserve load", | ||
128 | "03 - init withdraw loop", | ||
129 | "02 - save reserve"), | ||
130 | PERF_TALER_EXCHANGEDB_INIT_CMD_CREATE_WITHDRAW ("03 - withdraw", | ||
131 | "03 - denomination load", | ||
132 | "03 - reserve load"), | ||
133 | PERF_TALER_EXCHANGEDB_INIT_CMD_INSERT_WITHDRAW ("03 - insert withdraw", | ||
134 | "03 - withdraw"), | ||
135 | PERF_TALER_EXCHANGEDB_INIT_CMD_COMMIT_TRANSACTION ( | ||
136 | "03 - commit transaction"), | ||
137 | PERF_TALER_EXCHANGEDB_INIT_CMD_SAVE_ARRAY ("03 - coin array", | ||
138 | "03 - init withdraw loop", | ||
139 | "03 - withdraw", | ||
140 | NB_WITHDRAW_SAVE), | ||
141 | PERF_TALER_EXCHANGEDB_INIT_CMD_END_LOOP ("03 - withdraw init end loop", | ||
142 | "03 - init withdraw loop"), | ||
143 | PERF_TALER_EXCHANGEDB_INIT_CMD_DEBUG ("03 - withdraw init complete"), | ||
144 | // End of withdrawal initialization | ||
145 | // Deposit initialization | ||
146 | PERF_TALER_EXCHANGEDB_INIT_CMD_GET_TIME ("04 - time start"), | ||
147 | PERF_TALER_EXCHANGEDB_INIT_CMD_LOOP ("04 - deposit init loop", | ||
148 | NB_DEPOSIT_INIT), | ||
149 | PERF_TALER_EXCHANGEDB_INIT_CMD_START_TRANSACTION ("04 - start transaction"), | ||
150 | PERF_TALER_EXCHANGEDB_INIT_CMD_LOAD_ARRAY ("04 - coin load", | ||
151 | "04 - deposit init loop", | ||
152 | "03 - coin array"), | ||
153 | PERF_TALER_EXCHANGEDB_INIT_CMD_CREATE_DEPOSIT ("04 - deposit", | ||
154 | "04 - coin load"), | ||
155 | PERF_TALER_EXCHANGEDB_INIT_CMD_INSERT_DEPOSIT ("04 - insert deposit", | ||
156 | "04 - deposit"), | ||
157 | PERF_TALER_EXCHANGEDB_INIT_CMD_COMMIT_TRANSACTION ( | ||
158 | "04 - commit transaction"), | ||
159 | PERF_TALER_EXCHANGEDB_INIT_CMD_SAVE_ARRAY ("04 - deposit array", | ||
160 | "04 - deposit init loop", | ||
161 | "04 - deposit", | ||
162 | NB_DEPOSIT_SAVE), | ||
163 | PERF_TALER_EXCHANGEDB_INIT_CMD_END_LOOP ("04 - deposit init loop end", | ||
164 | "04 - deposit init loop"), | ||
165 | PERF_TALER_EXCHANGEDB_INIT_CMD_GET_TIME ("04 - time stop"), | ||
166 | PERF_TALER_EXCHANGEDB_INIT_CMD_GAUGER ("04 - gauger", | ||
167 | "04 - time start", | ||
168 | "04 - time stop", | ||
169 | "TEST", | ||
170 | "time to insert a deposit", | ||
171 | "deposit/sec", | ||
172 | NB_DEPOSIT_SAVE), | ||
173 | PERF_TALER_EXCHANGEDB_INIT_CMD_DEBUG ("04 - deposit init complete"), | ||
174 | // End of deposit initialization | ||
175 | PERF_TALER_EXCHANGEDB_INIT_CMD_END ("end"), | ||
176 | }; | ||
177 | |||
178 | test_allocate (); | ||
179 | ret = PERF_TALER_EXCHANGEDB_run_benchmark ("test-perf-taler-exchangedb", | ||
180 | "./test-exchange-db-postgres.conf", | ||
181 | init, | ||
182 | benchmark); | ||
183 | if (GNUNET_SYSERR == ret) | ||
184 | return 1; | ||
185 | if (GNUNET_NO == ret) | ||
186 | return 77; /* testcase skipped */ | ||
187 | return 0; | ||
188 | } | ||