int main(int argc, gchar **argv) { grn_rc rc; BenchmarkData data; BenchReporter *reporter; gint n = 100; rc = grn_init(); if (rc != GRN_SUCCESS) { g_print("failed to initialize Groonga: <%d>: %s\n", rc, grn_get_global_error_message()); return EXIT_FAILURE; } bench_init(&argc, &argv); data.context = g_new(grn_ctx, 1); data.base_dir = g_build_filename(g_get_tmp_dir(), "groonga-bench", NULL); data.name = "table"; data.name_size = strlen(data.name); data.path = g_build_filename(data.base_dir, "table", NULL); data.flags = DEFAULT_FLAGS; data.key_type = NULL; data.value_size = DEFAULT_VALUE_SIZE; data.encoding = GRN_ENC_DEFAULT; reporter = bench_reporter_new(); bench_reporter_register(reporter, "normal (persistent)", n, bench_setup, bench_normal, bench_teardown, &data); bench_reporter_register(reporter, "factory (persistent)", n, bench_setup, bench_factory, bench_teardown, &data); bench_reporter_register(reporter, "normal (temporary)", n, bench_setup, bench_normal_temporary, bench_teardown, &data); bench_reporter_register(reporter, "factory (temporary)", n, bench_setup, bench_factory_temporary, bench_teardown, &data); bench_reporter_run(reporter); g_object_unref(reporter); bench_utils_remove_path_recursive_force(data.base_dir); g_free(data.path); g_free(data.base_dir); g_free(data.context); bench_quit(); grn_fin(); return EXIT_SUCCESS; }
int main(int argc, gchar **argv) { BenchmarkData data; BenchReporter *reporter; gint n = 1000; grn_init(); bench_init(&argc, &argv); data.report_result = g_getenv("GROONGA_BENCH_REPORT_RESULT") != NULL; data.context = g_new(grn_ctx, 1); { const gchar *groonga_bench_n; groonga_bench_n = g_getenv("GROONGA_BENCH_N"); if (groonga_bench_n) { n = atoi(groonga_bench_n); } } reporter = bench_reporter_new(); #define REGISTER(label, setup) \ bench_reporter_register(reporter, label, n, \ bench_setup_ ## setup, \ bench_geo_distance, \ bench_teardown, \ &data) REGISTER("rectangular (WGS84)", rectangular_wgs84); REGISTER("rectangular (TOKYO)", rectangular_tgs); REGISTER("spherical (WGS84)", spherical_wgs84); REGISTER("spherical (TOKYO)", spherical_tgs); REGISTER("hubeny (WGS84)", hubeny_wgs84); REGISTER("hubeny (TOKYO)", hubeny_tgs); #undef REGISTER bench_reporter_run(reporter); g_object_unref(reporter); g_free(data.context); bench_quit(); grn_fin(); return 0; }