summaryrefslogtreecommitdiff
path: root/src/benchmark
diff options
context:
space:
mode:
authorMarcello Stanisci <marcello.stanisci@inria.fr>2016-05-30 18:45:57 +0200
committerMarcello Stanisci <marcello.stanisci@inria.fr>2016-05-30 18:45:57 +0200
commit66201bf9170b35e73ea08e9b955c1bff8b09dc67 (patch)
tree65e69d5524592700cc229ce122ff516d128e1016 /src/benchmark
parent925097c86df2707a381d10c75445f57110b47d83 (diff)
downloadexchange-66201bf9170b35e73ea08e9b955c1bff8b09dc67.tar.gz
exchange-66201bf9170b35e73ea08e9b955c1bff8b09dc67.tar.bz2
exchange-66201bf9170b35e73ea08e9b955c1bff8b09dc67.zip
invoking benchmark_run() after getting /keys from exchange. Still doesn't work with https
Diffstat (limited to 'src/benchmark')
-rwxr-xr-xsrc/benchmark/taler-exchange-benchmarkbin8756 -> 20440 bytes
-rw-r--r--src/benchmark/taler-exchange-benchmark.c118
2 files changed, 113 insertions, 5 deletions
diff --git a/src/benchmark/taler-exchange-benchmark b/src/benchmark/taler-exchange-benchmark
index 336d9fcca..86cb33e39 100755
--- a/src/benchmark/taler-exchange-benchmark
+++ b/src/benchmark/taler-exchange-benchmark
Binary files differ
diff --git a/src/benchmark/taler-exchange-benchmark.c b/src/benchmark/taler-exchange-benchmark.c
index 2b6608053..e1469d348 100644
--- a/src/benchmark/taler-exchange-benchmark.c
+++ b/src/benchmark/taler-exchange-benchmark.c
@@ -27,13 +27,104 @@
#include <gnunet/gnunet_curl_lib.h>
#include <microhttpd.h>
-
+/**
+ * How many coins the benchmark should operate on
+ */
static unsigned int pool_size = 100000;
/**
+ * Context for running the #ctx's event loop.
+ */
+static struct GNUNET_CURL_RescheduleContext *rc;
+
+/**
+ * Benchmark's task
+ */
+struct GNUNET_SCHEDULER_Task *benchmark_task;
+
+/**
+ * Main execution context for the main loop of the exchange.
+ */
+static struct GNUNET_CURL_Context *ctx;
+
+/**
+ * Handle to access the exchange.
+ */
+static struct TALER_EXCHANGE_Handle *exchange;
+
+/**
* URI under which the exchange is reachable during the benchmark.
*/
-#define EXCHANGE_URI "http://localhost:8081/"
+#define EXCHANGE_URI "http://localhost:8081"
+
+/**
+ * Run the main interpreter loop that performs exchange operations.
+ *
+ * @param cls contains the `struct InterpreterState`
+ */
+static void
+benchmark_run (void *cls)
+{
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO, "benchmark_run() invoked\n");
+}
+
+/**
+ * Functions of this type are called to provide the retrieved signing and
+ * denomination keys of the exchange. No TALER_EXCHANGE_*() functions should be called
+ * in this callback.
+ *
+ * @param cls closure
+ * @param keys information about keys of the exchange
+ */
+static void
+cert_cb (void *cls,
+ const struct TALER_EXCHANGE_Keys *keys)
+{
+ /* check that keys is OK */
+#define ERR(cond) do { if(!(cond)) break; GNUNET_break (0); GNUNET_SCHEDULER_shutdown(); return; } while (0)
+ ERR (NULL == keys);
+ ERR (0 == keys->num_sign_keys);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Read %u signing keys\n",
+ keys->num_sign_keys);
+ ERR (0 == keys->num_denom_keys);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Read %u denomination keys\n",
+ keys->num_denom_keys);
+#undef ERR
+
+ /* run actual tests via interpreter-loop */
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Certificate callback invoked, invoking benchmark_run()\n");
+ benchmark_task = GNUNET_SCHEDULER_add_now (&benchmark_run,
+ NULL);
+}
+
+/**
+ * Function run when the test terminates (good or bad).
+ * Cleans up our state.
+ *
+ * @param cls the interpreter state.
+ */
+static void
+do_shutdown (void *cls)
+{
+ if (NULL != exchange)
+ {
+ TALER_EXCHANGE_disconnect (exchange);
+ exchange = NULL;
+ }
+ if (NULL != ctx)
+ {
+ GNUNET_CURL_fini (ctx);
+ ctx = NULL;
+ }
+ if (NULL != rc)
+ {
+ GNUNET_CURL_gnunet_rc_destroy (rc);
+ rc = NULL;
+ }
+}
/**
* Main function that will be run by the scheduler.
@@ -43,6 +134,18 @@ static unsigned int pool_size = 100000;
static void
run (void *cls)
{
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO, "running run()\n");
+ ctx = GNUNET_CURL_init (&GNUNET_CURL_gnunet_scheduler_reschedule,
+ &rc);
+ GNUNET_assert (NULL != ctx);
+ rc = GNUNET_CURL_gnunet_rc_create (ctx);
+ exchange = TALER_EXCHANGE_connect (ctx,
+ EXCHANGE_URI,
+ &cert_cb, NULL,
+ TALER_EXCHANGE_OPTION_END);
+ GNUNET_assert (NULL != exchange);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "connected to exchange\n");
+ GNUNET_SCHEDULER_add_shutdown (&do_shutdown, NULL);
}
int
@@ -50,17 +153,22 @@ main (int argc,
char * const *argv)
{
/**
- * 1 Pool's size as an option
- * 2 Connection to the exchange
+ * 1 Pool's size as an option: DONE
+ * 2 Connection to the exchange: DONE, NOT TESTED
* 3 Allocation of large enough memory
* 4 Withdraw
*/
-
+ GNUNET_log_setup ("taler-exchange-benchmark",
+ "WARNING",
+ NULL);
const struct GNUNET_GETOPT_CommandLineOption options[] = {
{'s', "pool-size", NULL,
"How many coins this benchmark should instantiate", GNUNET_YES,
&GNUNET_GETOPT_set_uint, &pool_size}
};
+ GNUNET_assert (GNUNET_SYSERR !=
+ GNUNET_GETOPT_run ("taler-exchange-benchmark",
+ options, argc, argv));
GNUNET_SCHEDULER_run (&run, NULL);
}