diff options
author | Christian Grothoff <grothoff@gnunet.org> | 2023-03-31 13:50:32 +0200 |
---|---|---|
committer | Christian Grothoff <grothoff@gnunet.org> | 2023-03-31 13:50:32 +0200 |
commit | 6eed8917c37ad047ee95e964cd516d82aacac473 (patch) | |
tree | 5dedf24afa822f80325abbd407275f9de840b302 /src/exchangedb/test_exchangedb_by_j.c | |
parent | 9cce35d27027e1e72e44ac8965ae687d75f1c93d (diff) | |
download | exchange-6eed8917c37ad047ee95e964cd516d82aacac473.tar.xz |
fix exchangedb build errors
Diffstat (limited to 'src/exchangedb/test_exchangedb_by_j.c')
-rw-r--r-- | src/exchangedb/test_exchangedb_by_j.c | 133 |
1 files changed, 67 insertions, 66 deletions
diff --git a/src/exchangedb/test_exchangedb_by_j.c b/src/exchangedb/test_exchangedb_by_j.c index 9769d964b..24b24d5b0 100644 --- a/src/exchangedb/test_exchangedb_by_j.c +++ b/src/exchangedb/test_exchangedb_by_j.c @@ -74,8 +74,8 @@ static void run (void *cls) { static const unsigned int batches[] = {1, 2, 3, 4, 8, 16 }; - struct GNUNET_TIME_Relative times[sizeof (batches)/sizeof(*batches)]; - unsigned long long sqrs[sizeof (batches)/sizeof(*batches)]; + struct GNUNET_TIME_Relative times[sizeof (batches) / sizeof(*batches)]; + unsigned long long sqrs[sizeof (batches) / sizeof(*batches)]; struct GNUNET_CONFIGURATION_Handle *cfg = cls; const uint32_t num_partitions = 10; @@ -101,74 +101,75 @@ run (void *cls) memset (times, 0, sizeof (times)); memset (sqrs, 0, sizeof (sqrs)); for (unsigned int r = 0; r < ROUNDS; r++) - { + { for (unsigned int i = 0; i< 6; i++) + { + const char *sndr = "payto://x-taler-bank/localhost:8080/1"; + struct TALER_Amount value; + unsigned int batch_size = batches[i]; + unsigned int iterations = 16; // 1024*10; + struct TALER_ReservePublicKeyP reserve_pubs[iterations]; + struct GNUNET_TIME_Absolute now; + struct GNUNET_TIME_Timestamp ts; + struct GNUNET_TIME_Relative duration; + struct TALER_EXCHANGEDB_ReserveInInfo reserves[iterations]; + enum GNUNET_DB_QueryStatus results[iterations]; + unsigned long long duration_sq; + + GNUNET_assert (GNUNET_OK == + TALER_string_to_amount (CURRENCY ":1.000010", + &value)); + now = GNUNET_TIME_absolute_get (); + ts = GNUNET_TIME_timestamp_get (); + for (unsigned int r = 0; r<iterations; r++) { - const char *sndr = "payto://x-taler-bank/localhost:8080/1"; - struct TALER_Amount value; - unsigned int batch_size = batches[i]; - unsigned int iterations = 16;//1024*10; - struct TALER_ReservePublicKeyP reserve_pubs[iterations]; - struct GNUNET_TIME_Absolute now; - struct GNUNET_TIME_Timestamp ts; - struct GNUNET_TIME_Relative duration; - struct TALER_EXCHANGEDB_ReserveInInfo reserves[iterations]; - enum GNUNET_DB_QueryStatus results[iterations]; - unsigned long long duration_sq; - - GNUNET_assert (GNUNET_OK == - TALER_string_to_amount (CURRENCY ":1.000010", - &value)); - now = GNUNET_TIME_absolute_get (); - ts = GNUNET_TIME_timestamp_get (); - for (unsigned int r = 0; r<iterations; r++) - { - RND_BLK (&reserve_pubs[r]); - reserves[r].reserve_pub = &reserve_pubs[r]; - reserves[r].balance = &value; - reserves[r].execution_time = ts; - reserves[r].sender_account_details = sndr; - reserves[r].exchange_account_name = "name"; - reserves[r].wire_reference = r; - } - FAILIF (iterations != - plugin->batch2_reserves_in_insert (plugin->cls, - reserves, - iterations, - batch_size, - results)); - duration = GNUNET_TIME_absolute_get_duration (now); - times[i] = GNUNET_TIME_relative_add (times[i], - duration); - duration_sq = duration.rel_value_us * duration.rel_value_us; - GNUNET_assert (duration_sq / duration.rel_value_us == duration.rel_value_us); - GNUNET_assert (sqrs[i] + duration_sq >= sqrs[i]); - sqrs[i] += duration_sq; - fprintf (stdout, - "for a batchsize equal to %d it took %s\n", - batch_size, - GNUNET_STRINGS_relative_time_to_string (duration, - GNUNET_NO) ); - - system ("./test.sh"); //DELETE AFTER TIMER + RND_BLK (&reserve_pubs[r]); + reserves[r].reserve_pub = &reserve_pubs[r]; + reserves[r].balance = &value; + reserves[r].execution_time = ts; + reserves[r].sender_account_details = sndr; + reserves[r].exchange_account_name = "name"; + reserves[r].wire_reference = r; } + FAILIF (iterations != + plugin->batch2_reserves_in_insert (plugin->cls, + reserves, + iterations, + batch_size, + results)); + duration = GNUNET_TIME_absolute_get_duration (now); + times[i] = GNUNET_TIME_relative_add (times[i], + duration); + duration_sq = duration.rel_value_us * duration.rel_value_us; + GNUNET_assert (duration_sq / duration.rel_value_us == + duration.rel_value_us); + GNUNET_assert (sqrs[i] + duration_sq >= sqrs[i]); + sqrs[i] += duration_sq; + fprintf (stdout, + "for a batchsize equal to %d it took %s\n", + batch_size, + GNUNET_STRINGS_relative_time_to_string (duration, + GNUNET_NO) ); + + system ("./test.sh"); // DELETE AFTER TIMER } - for (unsigned int i = 0; i< 6; i++) - { - struct GNUNET_TIME_Relative avg; - double avg_dbl; - double variance; - - avg = GNUNET_TIME_relative_divide (times[i], - ROUNDS); - avg_dbl = avg.rel_value_us; - variance = sqrs[i] - (avg_dbl * avg_dbl * ROUNDS); - fprintf(stdout, - "Batch[%2u]: %8llu ± %6.0f\n", - batches[i], - (unsigned long long) avg.rel_value_us, - sqrt (variance / (ROUNDS-1))); - } + } + for (unsigned int i = 0; i< 6; i++) + { + struct GNUNET_TIME_Relative avg; + double avg_dbl; + double variance; + + avg = GNUNET_TIME_relative_divide (times[i], + ROUNDS); + avg_dbl = avg.rel_value_us; + variance = sqrs[i] - (avg_dbl * avg_dbl * ROUNDS); + fprintf (stdout, + "Batch[%2u]: %8llu ± %6.0f\n", + batches[i], + (unsigned long long) avg.rel_value_us, + sqrt (variance / (ROUNDS - 1))); + } result = 0; drop: |