diff options
Diffstat (limited to 'modules/benchmark/bench_results.c')
-rw-r--r-- | modules/benchmark/bench_results.c | 109 |
1 files changed, 69 insertions, 40 deletions
diff --git a/modules/benchmark/bench_results.c b/modules/benchmark/bench_results.c index 226f595c..27a33a65 100644 --- a/modules/benchmark/bench_results.c +++ b/modules/benchmark/bench_results.c @@ -32,13 +32,12 @@ typedef struct { int cores; int threads; char *mid; -} simple_machine; +} bench_machine; typedef struct { char *name; - float result; - int threads; - simple_machine *machine; + bench_value bvalue; + bench_machine *machine; int legacy; /* an old benchmark.conf result */ } bench_result; @@ -112,7 +111,7 @@ static int cpu_config_is_close(char *str0, char *str1) { return 0; } -static gen_machine_id(simple_machine *m) { +static gen_machine_id(bench_machine *m) { char *s; if (m) { if (m->mid != NULL) @@ -135,19 +134,19 @@ static gen_machine_id(simple_machine *m) { } } -simple_machine *simple_machine_new() { - simple_machine *m = NULL; - m = malloc(sizeof(simple_machine)); +bench_machine *bench_machine_new() { + bench_machine *m = NULL; + m = malloc(sizeof(bench_machine)); if (m) - memset(m, 0, sizeof(simple_machine)); + memset(m, 0, sizeof(bench_machine)); return m; } -simple_machine *simple_machine_this() { - simple_machine *m = NULL; +bench_machine *bench_machine_this() { + bench_machine *m = NULL; char *tmp; - m = simple_machine_new(); + m = bench_machine_new(); if (m) { m->board = module_call_method("devices::getMotherboard"); m->cpu_name = module_call_method("devices::getProcessorName"); @@ -159,18 +158,12 @@ simple_machine *simple_machine_this() { free(tmp); cpu_procs_cores_threads(&m->processors, &m->cores, &m->threads); - /* - tmp = module_call_method("devices::getProcessorCount"); - m->threads = atoi(tmp); - free(tmp); - */ - gen_machine_id(m); } return m; } -void simple_machine_free(simple_machine *s) { +void bench_machine_free(bench_machine *s) { if (s) { free(s->board); free(s->cpu_name); @@ -183,20 +176,19 @@ void simple_machine_free(simple_machine *s) { void bench_result_free(bench_result *s) { if (s) { free(s->name); - simple_machine_free(s->machine); + bench_machine_free(s->machine); } } -bench_result *bench_result_this_machine(const char *bench_name, float result, int threads) { +bench_result *bench_result_this_machine(const char *bench_name, bench_value r) { bench_result *b = NULL; b = malloc(sizeof(bench_result)); if (b) { memset(b, 0, sizeof(bench_result)); - b->machine = simple_machine_this(); + b->machine = bench_machine_this(); b->name = strdup(bench_name); - b->result = result; - b->threads = threads; + b->bvalue = r; b->legacy = 0; } return b; @@ -221,6 +213,32 @@ static int nx_prefix(const char *str) { return -1; } +/* old results didn't store the actual number of threads used */ +static int guess_threads_old_result(const char *bench_name, int threads_available) { +#define CHKBNAME(BN) (strcmp(bench_name, BN) == 0) + if (CHKBNAME("CPU Fibonacci") ) + return 1; + if (CHKBNAME("FPU FFT") ) { + if (threads_available >= 4) + return 4; + else if (threads_available >= 2) + return 2; + else + return 1; + } + if (CHKBNAME("CPU N-Queens") ) { + if (threads_available >= 10) + return 10; + else if (threads_available >= 5) + return 5; + else if (threads_available >= 2) + return 2; + else + return 1; + } + return threads_available; +} + bench_result *bench_result_benchmarkconf(const char *section, const char *key, char **values) { bench_result *b = NULL; char *s0, *s1, *s2; @@ -232,13 +250,16 @@ bench_result *bench_result_benchmarkconf(const char *section, const char *key, c b = malloc(sizeof(bench_result)); if (b) { memset(b, 0, sizeof(bench_result)); - b->machine = simple_machine_new(); + b->machine = bench_machine_new(); b->name = strdup(section); if (vl >= 10) { /* the 11th could be empty */ b->machine->mid = strdup(key); - b->result = atof(values[0]); - b->threads = atoi(values[1]); + /* first try as bench_value, then try as double 'result' only */ + b->bvalue = bench_value_from_str(values[0]); + if (b->bvalue.result == -1) + b->bvalue.result = atoi(values[0]); + b->bvalue.threads_used = atoi(values[1]); b->machine->board = strdup(values[2]); b->machine->cpu_name = strdup(values[3]); b->machine->cpu_desc = strdup(values[4]); @@ -251,7 +272,7 @@ bench_result *bench_result_benchmarkconf(const char *section, const char *key, c b->machine->ogl_renderer = strdup(values[10]); b->legacy = 0; } else if (vl >= 2) { - b->result = atof(values[0]); + b->bvalue.result = atof(values[0]); b->legacy = 1; /* old old format has prefix before cpu name (ex: 4x Pentium...) */ @@ -259,11 +280,9 @@ bench_result *bench_result_benchmarkconf(const char *section, const char *key, c if (nx > 0) { b->machine->cpu_name = strdup(strchr(key, 'x') + 1); b->machine->threads = nx; - b->threads = nx; } else { b->machine->cpu_name = strdup(key); b->machine->threads = 1; - b->threads = 1; } b->machine->cpu_config = strdup(values[1]); @@ -271,9 +290,10 @@ bench_result *bench_result_benchmarkconf(const char *section, const char *key, c nx = nx_prefix(values[1]); if (nx > 0) { b->machine->threads = nx; - b->threads = nx; } + b->bvalue.threads_used = guess_threads_old_result(section, b->machine->threads); + /* If the clock rate in the id string is more than the * config string, use that. Older hardinfo used current cpu freq * instead of max freq. @@ -295,7 +315,7 @@ bench_result *bench_result_benchmarkconf(const char *section, const char *key, c n = atof(s1+1); n *= m; - s1 = g_strdup_printf("%dx %.2f %s", b->threads, n, _("MHz")); + s1 = g_strdup_printf("%dx %.2f %s", b->bvalue.threads_used, n, _("MHz")); if ( cpu_config_cmp(b->machine->cpu_config, s1) == -1 && !cpu_config_is_close(b->machine->cpu_config, s1) ) { free(b->machine->cpu_config); @@ -327,8 +347,9 @@ bench_result *bench_result_benchmarkconf(const char *section, const char *key, c char *bench_result_benchmarkconf_line(bench_result *b) { char *cpu_config = cpu_config_retranslate(b->machine->cpu_config, 1, 0); - char *ret = g_strdup_printf("%s=%.2f|%d|%s|%s|%s|%s|%d|%d|%d|%d|%s\n", - b->machine->mid, b->result, b->threads, + char *bv = bench_value_to_str(b->bvalue); + char *ret = g_strdup_printf("%s=%s|%d|%s|%s|%s|%s|%d|%d|%d|%d|%s\n", + b->machine->mid, bv, b->bvalue.threads_used, (b->machine->board != NULL) ? b->machine->board : "", b->machine->cpu_name, (b->machine->cpu_desc != NULL) ? b->machine->cpu_desc : "", @@ -338,10 +359,11 @@ char *bench_result_benchmarkconf_line(bench_result *b) { (b->machine->ogl_renderer != NULL) ? b->machine->ogl_renderer : "" ); free(cpu_config); + free(bv); return ret; } -char *bench_result_more_info(bench_result *b) { +static char *bench_result_more_info_less(bench_result *b) { char *memory = (b->machine->memory_kiB > 0) ? g_strdup_printf("%d %s", b->machine->memory_kiB, _("kiB") ) @@ -359,7 +381,7 @@ char *bench_result_more_info(bench_result *b) { /* ogl rend */ "%s=%s\n" /* mem */ "%s=%s\n", _("Benchmark Result"), - _("Threads"), b->threads, + _("Threads"), b->bvalue.threads_used, b->legacy ? _("Note") : "#Note", b->legacy ? _("This result is from an old version of HardInfo. Results might not be comparable to current version. Some details are missing.") : "", _("Machine"), @@ -375,11 +397,12 @@ char *bench_result_more_info(bench_result *b) { return ret; } -char *bench_result_more_info_complete(bench_result *b) { +static char *bench_result_more_info_complete(bench_result *b) { return g_strdup_printf("[%s]\n" /* bench name */"%s=%s\n" - /* result */ "%s=%0.2f\n" /* threads */ "%s=%d\n" + /* result */ "%s=%0.2f\n" + /* elapsed */ "%s=%0.2f\n" /* legacy */ "%s=%s\n" "[%s]\n" /* board */ "%s=%s\n" @@ -394,8 +417,9 @@ char *bench_result_more_info_complete(bench_result *b) { /* cfg_val */ "%s=%.2f\n", _("Benchmark Result"), _("Benchmark"), b->name, - _("Result"), b->result, - _("Threads"), b->threads, + _("Threads"), b->bvalue.threads_used, + _("Result"), b->bvalue.result, + _("Elapsed Time"), b->bvalue.elapsed_time, b->legacy ? _("Note") : "#Note", b->legacy ? _("This result is from an old version of HardInfo. Results might not be comparable to current version. Some details are missing.") : "", _("Machine"), @@ -411,3 +435,8 @@ char *bench_result_more_info_complete(bench_result *b) { _("cfg_val"), cpu_config_val(b->machine->cpu_config) ); } + +char *bench_result_more_info(bench_result *b) { + //return bench_result_more_info_complete(b); + return bench_result_more_info_less(b); +} |