diff options
author | Leandro A. F. Pereira <leandro@hardinfo.org> | 2007-01-20 01:33:01 +0000 |
---|---|---|
committer | Leandro A. F. Pereira <leandro@hardinfo.org> | 2007-01-20 01:33:01 +0000 |
commit | c38d62dba479a8a69703d0fb010ed34ac2ebc685 (patch) | |
tree | 2b874f1b890be1d73bd09bd332b8607c001703ac /hardinfo2/benchmark.c | |
parent | fa0fa92bd3f1f0bad206b3a835b562839d9d895c (diff) |
Better benchmark result handling when using synchronized data.
Diffstat (limited to 'hardinfo2/benchmark.c')
-rw-r--r-- | hardinfo2/benchmark.c | 82 |
1 files changed, 34 insertions, 48 deletions
diff --git a/hardinfo2/benchmark.c b/hardinfo2/benchmark.c index a4501e43..7f5025de 100644 --- a/hardinfo2/benchmark.c +++ b/hardinfo2/benchmark.c @@ -56,33 +56,24 @@ static ModuleEntry entries[] = { { NULL } }; -static gchar *__benchmark_include_results(gchar * results, +static gchar *__benchmark_include_results(gdouble result, const gchar * benchmark, ShellOrderType order_type) { GKeyFile *conf; gchar **machines; - gchar *path; + gchar *path, *results = ""; int i; conf = g_key_file_new(); - path = g_build_filename(params.path_data, "benchmark.conf", NULL); - g_key_file_load_from_file(conf, path, 0, NULL); - - machines = g_key_file_get_keys(conf, benchmark, NULL, NULL); - for (i = 0; machines && machines[i]; i++) { - gchar *value = g_key_file_get_value(conf, benchmark, machines[i], NULL); - results = g_strconcat(results, machines[i], "=", value, "\n", NULL); - g_free(value); + path = g_build_filename(g_get_home_dir(), ".hardinfo", "benchmark.conf", NULL); + if (!g_file_test(path, G_FILE_TEST_EXISTS)) { + DEBUG("local benchmark.conf not found, trying system-wide"); + g_free(path); + path = g_build_filename(params.path_data, "benchmark.conf", NULL); } - g_strfreev(machines); - g_free(path); - g_key_file_free(conf); - - conf = g_key_file_new(); - path = g_build_filename(g_get_home_dir(), ".hardinfo", "benchmark.conf", NULL); g_key_file_load_from_file(conf, path, 0, NULL); machines = g_key_file_get_keys(conf, benchmark, NULL, NULL); @@ -96,33 +87,32 @@ static gchar *__benchmark_include_results(gchar * results, g_free(path); g_key_file_free(conf); + DEBUG("results = %s", results); + return g_strdup_printf("[$ShellParam$]\n" "Zebra=1\n" "OrderType=%d\n" - "ViewType=3\n%s", order_type, results); + "ViewType=3\n" + "[%s]\n" + "<i>This Machine</i>=%.3f\n" + "%s", order_type, benchmark, result, results); } -static gchar *benchmark_include_results_reverse(gchar * results, +static gchar *benchmark_include_results_reverse(gdouble result, const gchar * benchmark) { - return __benchmark_include_results(results, benchmark, + return __benchmark_include_results(result, benchmark, SHELL_ORDER_DESCENDING); } -static gchar *benchmark_include_results(gchar * results, +static gchar *benchmark_include_results(gdouble result, const gchar * benchmark) { - return __benchmark_include_results(results, benchmark, + return __benchmark_include_results(result, benchmark, SHELL_ORDER_ASCENDING); } static gdouble bench_results[BENCHMARK_N_ENTRIES]; -static gchar *bench_zlib = NULL, - *bench_fib = NULL, - *bench_md5 = NULL, - *bench_sha1 = NULL, - *bench_fish = NULL, - *bench_ray = NULL; #include <arch/common/fib.h> #include <arch/common/zlib.h> @@ -133,79 +123,73 @@ static gchar *bench_zlib = NULL, gchar *callback_zlib() { - return g_strdup(bench_zlib); + return benchmark_include_results_reverse(bench_results[BENCHMARK_ZLIB], "CPU ZLib"); } gchar *callback_raytr() { - return g_strdup(bench_ray); + return benchmark_include_results(bench_results[BENCHMARK_RAYTRACE], "FPU Raytracing"); } gchar *callback_bfsh() { - return g_strdup(bench_fish); + return benchmark_include_results(bench_results[BENCHMARK_BLOWFISH], "CPU Blowfish"); } gchar *callback_md5() { - return g_strdup(bench_md5); + return benchmark_include_results_reverse(bench_results[BENCHMARK_MD5], "CPU MD5"); } gchar *callback_fib() { - return g_strdup(bench_fib); + return benchmark_include_results(bench_results[BENCHMARK_FIB], "CPU Fibonacci"); } gchar *callback_sha1() { - return g_strdup(bench_sha1); + return benchmark_include_results_reverse(bench_results[BENCHMARK_SHA1], "CPU SHA1"); } void scan_zlib(gboolean reload) { SCAN_START(); - g_free(bench_zlib); - bench_zlib = benchmark_zlib(); + benchmark_zlib(); SCAN_END(); } void scan_raytr(gboolean reload) { SCAN_START(); - g_free(bench_ray); - bench_ray = benchmark_raytrace(); + benchmark_raytrace(); SCAN_END(); } void scan_bfsh(gboolean reload) { SCAN_START(); - g_free(bench_fish); - bench_fish = benchmark_fish(); + benchmark_fish(); SCAN_END(); } void scan_md5(gboolean reload) { SCAN_START(); - g_free(bench_md5); - bench_md5 = benchmark_md5(); + benchmark_md5(); SCAN_END(); } void scan_fib(gboolean reload) { SCAN_START(); - g_free(bench_fib); - bench_fib = benchmark_fib(); + benchmark_fib(); SCAN_END(); } void scan_sha1(gboolean reload) { SCAN_START(); - g_free(bench_sha1); - bench_sha1 = benchmark_sha1(); + benchmark_sha1(); SCAN_END(); } @@ -213,9 +197,11 @@ const gchar *hi_note_func(gint entry) { switch (entry) { case BENCHMARK_ZLIB: + return "Results in KiB/second. Higher is better."; + case BENCHMARK_MD5: case BENCHMARK_SHA1: - return "Results in bytes/second. Higher is better."; + return "Results in MiB/second. Higher is better."; case BENCHMARK_RAYTRACE: case BENCHMARK_BLOWFISH: @@ -294,13 +280,13 @@ hi_module_init(void) { static SyncEntry se[] = { { - .fancy_name = "Send Benchmark results", + .fancy_name = "Send Benchmark Results", .name = "SendBenchmarkResults", .save_to = NULL, .get_data = get_benchmark_results }, { - .fancy_name = "Receive Benchmark results", + .fancy_name = "Receive Benchmark Results", .name = "RecvBenchmarkResults", .save_to = "benchmark.conf", .get_data = NULL |