diff --git a/benchmark/benchmark.c b/benchmark/benchmark.c index 33ac68a54..047af131d 100644 --- a/benchmark/benchmark.c +++ b/benchmark/benchmark.c @@ -34,6 +34,7 @@ static gboolean opt_machine_readable = FALSE; static gchar* opt_path = NULL; static gchar* opt_semantics = NULL; static gchar* opt_template = NULL; +static gchar* opt_namespace = NULL; static JSemantics* j_benchmark_semantics = NULL; @@ -115,6 +116,7 @@ j_benchmark_add(gchar const* name, BenchmarkFunc benchmark_func) run->iterations = 0; run->operations = 0; run->bytes = 0; + run->namespace = opt_namespace ? opt_namespace : "benchmark"; j_benchmarks = g_list_prepend(j_benchmarks, run); } @@ -301,6 +303,7 @@ main(int argc, char** argv) { "path", 'p', 0, G_OPTION_ARG_STRING, &opt_path, "Benchmark path to use", NULL }, { "semantics", 's', 0, G_OPTION_ARG_STRING, &opt_semantics, "Semantics to use", NULL }, { "template", 't', 0, G_OPTION_ARG_STRING, &opt_template, "Semantics template to use", NULL }, + { "namespace", 'n', 0, G_OPTION_ARG_STRING, &opt_namespace, "Namespace for benchmark to use", NULL }, { NULL, 0, 0, 0, NULL, NULL, NULL } }; @@ -373,6 +376,7 @@ main(int argc, char** argv) g_free(opt_path); g_free(opt_semantics); g_free(opt_template); + g_free(opt_namespace); return 0; } diff --git a/benchmark/benchmark.h b/benchmark/benchmark.h index f78e40b8d..4b7f21907 100644 --- a/benchmark/benchmark.h +++ b/benchmark/benchmark.h @@ -30,6 +30,8 @@ struct BenchmarkRun guint iterations; guint64 operations; guint64 bytes; + + gchar* namespace; }; typedef struct BenchmarkRun BenchmarkRun; diff --git a/benchmark/object/object.c b/benchmark/object/object.c index 12d8c1e4a..8ffc32804 100644 --- a/benchmark/object/object.c +++ b/benchmark/object/object.c @@ -51,7 +51,7 @@ _benchmark_object_create(BenchmarkRun* run, gboolean use_batch) g_autofree gchar* name = NULL; name = g_strdup_printf("benchmark-%d", i); - object = j_object_new("benchmark", name); + object = j_object_new(run->namespace, name); j_object_create(object, batch); j_object_delete(object, delete_batch); @@ -110,7 +110,7 @@ _benchmark_object_delete(BenchmarkRun* run, gboolean use_batch) g_autofree gchar* name = NULL; name = g_strdup_printf("benchmark-%d", i); - object = j_object_new("benchmark", name); + object = j_object_new(run->namespace, name); j_object_create(object, batch); } @@ -125,7 +125,7 @@ _benchmark_object_delete(BenchmarkRun* run, gboolean use_batch) g_autofree gchar* name = NULL; name = g_strdup_printf("benchmark-%d", i); - object = j_object_new("benchmark", name); + object = j_object_new(run->namespace, name); j_object_delete(object, batch); @@ -178,7 +178,7 @@ _benchmark_object_status(BenchmarkRun* run, gboolean use_batch) semantics = j_benchmark_get_semantics(); batch = j_batch_new(semantics); - object = j_object_new("benchmark", "benchmark"); + object = j_object_new(run->namespace, "benchmark"); j_object_create(object, batch); j_object_write(object, dummy, 1, 0, &size, batch); @@ -245,7 +245,7 @@ _benchmark_object_read(BenchmarkRun* run, gboolean use_batch, guint block_size) semantics = j_benchmark_get_semantics(); batch = j_batch_new(semantics); - object = j_object_new("benchmark", "benchmark"); + object = j_object_new(run->namespace, "benchmark"); j_object_create(object, batch); for (guint i = 0; i < n; i++) @@ -320,7 +320,7 @@ _benchmark_object_write(BenchmarkRun* run, gboolean use_batch, guint block_size) semantics = j_benchmark_get_semantics(); batch = j_batch_new(semantics); - object = j_object_new("benchmark", "benchmark"); + object = j_object_new(run->namespace, "benchmark"); j_object_create(object, batch); ret = j_batch_execute(batch); g_assert_true(ret); @@ -393,7 +393,7 @@ _benchmark_object_unordered_create_delete(BenchmarkRun* run, gboolean use_batch) g_autofree gchar* name = NULL; name = g_strdup_printf("benchmark-%d", i); - object = j_object_new("benchmark", name); + object = j_object_new(run->namespace, name); j_object_create(object, batch); j_object_delete(object, batch);