aboutsummaryrefslogtreecommitdiff
path: root/modules/benchmark.c
diff options
context:
space:
mode:
Diffstat (limited to 'modules/benchmark.c')
-rw-r--r--modules/benchmark.c139
1 files changed, 97 insertions, 42 deletions
diff --git a/modules/benchmark.c b/modules/benchmark.c
index 50fddf4d..857904a8 100644
--- a/modules/benchmark.c
+++ b/modules/benchmark.c
@@ -30,6 +30,8 @@
#include "benchmark.h"
+#include "benchmark/bench_results.c"
+
void scan_fft(gboolean reload);
void scan_raytr(gboolean reload);
void scan_bfsh(gboolean reload);
@@ -186,14 +188,62 @@ static gchar *clean_cpuname(gchar *cpuname)
return tmp;
}
+gchar *hi_more_info(gchar * entry)
+{
+ gchar *info = moreinfo_lookup_with_prefix("BENCH", entry);
+ if (info)
+ return g_strdup(info);
+ return g_strdup("?");
+}
+
+gchar *hi_get_field(gchar * field)
+{
+ gchar *info = moreinfo_lookup_with_prefix("BENCH", field);
+ if (info)
+ return g_strdup(info);
+ return g_strdup(field);
+}
+
+static void br_mi_add(char **results_list, bench_result *b, gboolean select) {
+ gchar *ckey, *rkey;
+
+ ckey = hardinfo_clean_label(b->machine->cpu_name, 0);
+ rkey = strdup(b->machine->mid);
+
+ *results_list = h_strdup_cprintf("$%s%s$%s=%.2f|%s\n", *results_list,
+ select ? "*" : "", rkey, ckey,
+ b->result, b->machine->cpu_config);
+
+ moreinfo_add_with_prefix("BENCH", rkey, bench_result_more_info(b) );
+
+ g_free(ckey);
+ g_free(rkey);
+}
+
static gchar *__benchmark_include_results(gdouble result,
const gchar * benchmark,
ShellOrderType order_type)
{
+ bench_result *b = NULL;
GKeyFile *conf;
- gchar **machines;
+ gchar **machines, *temp = NULL;;
gchar *path, *results = g_strdup(""), *return_value, *processor_frequency, *processor_name;
- int i;
+ int i, n_threads;
+
+ moreinfo_del_with_prefix("BENCH");
+
+ if (result > 0.0) {
+ temp = module_call_method("devices::getProcessorCount");
+ n_threads = temp ? atoi(temp) : 1;
+ g_free(temp); temp = NULL;
+
+ b = bench_result_this_machine(benchmark, result, n_threads);
+ br_mi_add(&results, b, 1);
+
+ temp = bench_result_benchmarkconf_line(b);
+ printf("[%s]\n%s", benchmark, temp);
+ g_free(temp); temp = NULL;
+ }
conf = g_key_file_new();
@@ -205,56 +255,40 @@ static gchar *__benchmark_include_results(gdouble result,
}
g_key_file_load_from_file(conf, path, 0, NULL);
+ g_key_file_set_list_separator(conf, '|');
machines = g_key_file_get_keys(conf, benchmark, NULL, NULL);
for (i = 0; machines && machines[i]; i++) {
- gchar *value, *cleaned_machine;
+ gchar **values;
+ bench_result *sbr;
- 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);
+ values = g_key_file_get_string_list(conf, benchmark, machines[i], NULL, NULL);
- g_free(value);
- g_free(cleaned_machine);
+ sbr = bench_result_benchmarkconf(benchmark, machines[i], values);
+ br_mi_add(&results, sbr, 0);
+
+ bench_result_free(sbr);
+ g_strfreev(values);
}
g_strfreev(machines);
g_free(path);
g_key_file_free(conf);
- if (result > 0.0f) {
- 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=%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_value = g_strdup_printf("[$ShellParam$]\n"
+ "Zebra=1\n"
+ "OrderType=%d\n"
+ "ViewType=4\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);
+
+ bench_result_free(b);
return return_value;
}
@@ -388,6 +422,27 @@ static void do_benchmark(void (*benchmark_function)(void), int entry)
bench_image = icon_cache_get_image("benchmark.png");
gtk_widget_show(bench_image);
+#if GTK_CHECK_VERSION(3, 0, 0)
+ GtkWidget *button;
+ GtkWidget *content_area;
+ GtkWidget *hbox;
+ GtkWidget *label;
+
+ bench_dialog = gtk_dialog_new_with_buttons("",
+ NULL,
+ GTK_DIALOG_MODAL,
+ _("Cancel"),
+ GTK_RESPONSE_ACCEPT,
+ NULL);
+ content_area = gtk_dialog_get_content_area(GTK_DIALOG(bench_dialog));
+ label = gtk_label_new(_("Benchmarking. Please do not move your mouse " \
+ "or press any keys."));
+ hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 5);
+ gtk_box_pack_start(GTK_BOX(hbox), bench_image, TRUE, TRUE, 5);
+ gtk_box_pack_end(GTK_BOX(hbox), label, TRUE, TRUE, 5);
+ gtk_container_add(GTK_CONTAINER (content_area), hbox);
+ gtk_widget_show_all(bench_dialog);
+#else
bench_dialog = gtk_message_dialog_new(GTK_WINDOW(shell_get_main_shell()->window),
GTK_DIALOG_MODAL,
GTK_MESSAGE_INFO,
@@ -398,6 +453,7 @@ static void do_benchmark(void (*benchmark_function)(void), int entry)
gtk_dialog_add_buttons(GTK_DIALOG(bench_dialog),
_("Cancel"), GTK_RESPONSE_ACCEPT, NULL);
gtk_message_dialog_set_image(GTK_MESSAGE_DIALOG(bench_dialog), bench_image);
+#endif
while (gtk_events_pending()) {
gtk_main_iteration();
@@ -686,4 +742,3 @@ gchar **hi_module_get_dependencies(void)
return deps;
}
-