diff options
author | Simon Quigley <tsimonq2@ubuntu.com> | 2017-08-16 04:32:39 -0500 |
---|---|---|
committer | Simon Quigley <tsimonq2@ubuntu.com> | 2017-08-16 04:32:39 -0500 |
commit | 82306ca849c0710209e5a39754f446d0335a276d (patch) | |
tree | 8d297400e5c36357b9147401631e653e035283d3 /modules/benchmark.c | |
parent | 21a53faf18b01a65a341115000e97d70b37c750c (diff) | |
parent | 9a9db98089717990cd5e0eef529f6bb0819ebe46 (diff) |
Updated version 0.5.1+git20170815 from 'upstream/0.5.1+git20170815'
with Debian dir 36bf8e7e43d9f6621a63c79a597af2f4f76271b7
Diffstat (limited to 'modules/benchmark.c')
-rw-r--r-- | modules/benchmark.c | 100 |
1 files changed, 63 insertions, 37 deletions
diff --git a/modules/benchmark.c b/modules/benchmark.c index 94997df8..50fddf4d 100644 --- a/modules/benchmark.c +++ b/modules/benchmark.c @@ -36,6 +36,7 @@ void scan_bfsh(gboolean reload); void scan_cryptohash(gboolean reload); void scan_fib(gboolean reload); void scan_nqueens(gboolean reload); +void scan_zlib(gboolean reload); void scan_gui(gboolean reload); gchar *callback_fft(); @@ -44,6 +45,7 @@ gchar *callback_bfsh(); gchar *callback_fib(); gchar *callback_cryptohash(); gchar *callback_nqueens(); +gchar *callback_zlib(); gchar *callback_gui(); static ModuleEntry entries[] = { @@ -51,9 +53,12 @@ static ModuleEntry entries[] = { {N_("CPU CryptoHash"), "cryptohash.png", callback_cryptohash, scan_cryptohash, MODULE_FLAG_NONE}, {N_("CPU Fibonacci"), "nautilus.png", callback_fib, scan_fib, MODULE_FLAG_NONE}, {N_("CPU N-Queens"), "nqueens.png", callback_nqueens, scan_nqueens, MODULE_FLAG_NONE}, + {N_("CPU Zlib"), "file-roller.png", callback_zlib, scan_zlib, MODULE_FLAG_NONE}, {N_("FPU FFT"), "fft.png", callback_fft, scan_fft, MODULE_FLAG_NONE}, {N_("FPU Raytracing"), "raytrace.png", callback_raytr, scan_raytr, MODULE_FLAG_NONE}, +#if !GTK_CHECK_VERSION(3,0,0) {N_("GPU Drawing"), "module.png", callback_gui, scan_gui, MODULE_FLAG_NO_REMOTE}, +#endif {NULL} }; @@ -187,30 +192,30 @@ static gchar *__benchmark_include_results(gdouble result, { GKeyFile *conf; gchar **machines; - gchar *path, *results = g_strdup(""), *return_value, *processor_frequency; + gchar *path, *results = g_strdup(""), *return_value, *processor_frequency, *processor_name; int i; conf = g_key_file_new(); 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); + DEBUG("local benchmark.conf not found, trying system-wide"); + g_free(path); + 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, *cleaned_machine; + gchar *value, *cleaned_machine; - value = g_key_file_get_value(conf, benchmark, machines[i], NULL); - cleaned_machine = clean_cpuname(machines[i]); - results = h_strconcat(results, cleaned_machine, "=", value, "\n", NULL); + value = g_key_file_get_value(conf, benchmark, machines[i], NULL); + cleaned_machine = clean_cpuname(machines[i]); + results = h_strconcat(results, cleaned_machine, "=", value, "\n", NULL); - g_free(value); - g_free(cleaned_machine); + g_free(value); + g_free(cleaned_machine); } g_strfreev(machines); @@ -218,30 +223,37 @@ static gchar *__benchmark_include_results(gdouble result, g_key_file_free(conf); if (result > 0.0f) { - processor_frequency = module_call_method("devices::getProcessorFrequency"); - return_value = g_strdup_printf(_("[$ShellParam$]\n" - "Zebra=1\n" - "OrderType=%d\n" - "ViewType=3\n" - "ColumnTitle$Extra1=CPU Clock\n" - "ColumnTitle$Progress=Results\n" - "ColumnTitle$TextValue=CPU\n" - "ShowColumnHeaders=true\n" - "[%s]\n" - "<big><b>This Machine</b></big>=%.3f|%s MHz\n" - "%s"), order_type, benchmark, result, processor_frequency, results); + processor_name = module_call_method("devices::getProcessorName"); + processor_frequency = module_call_method("devices::getProcessorFrequencyDesc"); + return_value = g_strdup_printf("[$ShellParam$]\n" + "Zebra=1\n" + "OrderType=%d\n" + "ViewType=3\n" + "ColumnTitle$Extra1=%s\n" /* CPU Clock */ + "ColumnTitle$Progress=%s\n" /* Results */ + "ColumnTitle$TextValue=%s\n" /* CPU */ + "ShowColumnHeaders=true\n" + "[%s]\n" + "<big><b>%s</b></big>=%.3f|%s\n" + "%s", order_type, + _("CPU Config"), _("Results"), _("CPU"), + benchmark, + processor_name, result, processor_frequency, results); g_free(processor_frequency); + g_free(processor_name); } else { - return_value = g_strdup_printf(_("[$ShellParam$]\n" - "Zebra=1\n" - "OrderType=%d\n" - "ViewType=3\n" - "ColumnTitle$Extra1=CPU Clock\n" - "ColumnTitle$Progress=Results\n" - "ColumnTitle$TextValue=CPU\n" - "ShowColumnHeaders=true\n" - "[%s]\n" - "%s"), order_type, benchmark, results); + return_value = g_strdup_printf("[$ShellParam$]\n" + "Zebra=1\n" + "OrderType=%d\n" + "ViewType=3\n" + "ColumnTitle$Extra1=%s\n" /* CPU Clock */ + "ColumnTitle$Progress=%s\n" /* Results */ + "ColumnTitle$TextValue=%s\n" /* CPU */ + "ShowColumnHeaders=true\n" + "[%s]\n%s", + order_type, + _("CPU Config"), _("Results"), _("CPU"), + benchmark, results); } return return_value; } @@ -306,6 +318,12 @@ gchar *callback_fib() "CPU Fibonacci"); } +gchar *callback_zlib() +{ + return benchmark_include_results(bench_results[BENCHMARK_ZLIB], + "CPU Zlib"); +} + typedef struct _BenchmarkDialog BenchmarkDialog; struct _BenchmarkDialog { GtkWidget *dialog; @@ -348,7 +366,7 @@ static gboolean do_benchmark_handler(GIOChannel *source, static void do_benchmark(void (*benchmark_function)(void), int entry) { int old_priority = 0; - + if (params.gui_running && !sending_benchmark_results) { gchar *argv[] = { params.argv0, "-b", entries[entry].name, "-m", "benchmark.so", "-a", NULL }; @@ -364,7 +382,7 @@ static void do_benchmark(void (*benchmark_function)(void), int entry) shell_view_set_enabled(FALSE); shell_status_update(bench_status); - + g_free(bench_status); bench_image = icon_cache_get_image("benchmark.png"); @@ -388,7 +406,7 @@ static void do_benchmark(void (*benchmark_function)(void), int entry) benchmark_dialog = g_new0(BenchmarkDialog, 1); benchmark_dialog->dialog = bench_dialog; benchmark_dialog->result = -1.0f; - + if (!g_path_is_absolute(params.argv0)) { spawn_flags |= G_SPAWN_SEARCH_PATH; } @@ -432,7 +450,7 @@ static void do_benchmark(void (*benchmark_function)(void), int entry) return; } - + gtk_widget_destroy(bench_dialog); g_free(benchmark_dialog); shell_status_set_enabled(TRUE); @@ -504,12 +522,20 @@ void scan_fib(gboolean reload) SCAN_END(); } +void scan_zlib(gboolean reload) +{ + SCAN_START(); + do_benchmark(benchmark_zlib, BENCHMARK_ZLIB); + SCAN_END(); +} + const gchar *hi_note_func(gint entry) { switch (entry) { case BENCHMARK_CRYPTOHASH: return _("Results in MiB/second. Higher is better."); + case BENCHMARK_ZLIB: case BENCHMARK_GUI: return _("Results in HIMarks. Higher is better."); @@ -595,7 +621,7 @@ static gchar *get_benchmark_results() g_free(machineram); sending_benchmark_results = FALSE; - + return result; } |