diff options
Diffstat (limited to 'modules')
-rw-r--r-- | modules/benchmark.c | 77 | ||||
-rw-r--r-- | modules/benchmark/bench_results.c | 155 |
2 files changed, 12 insertions, 220 deletions
diff --git a/modules/benchmark.c b/modules/benchmark.c index 4db2062e..6d36100f 100644 --- a/modules/benchmark.c +++ b/modules/benchmark.c @@ -379,42 +379,6 @@ gint bench_result_sort(gconstpointer a, gconstpointer b) return 0; } -static GSList *benchmark_include_results_conf(const gchar *path, - bench_value r, - const gchar *benchmark) -{ - GKeyFile *conf; - gchar **machines; - gchar *results = g_strdup(""); - GSList *result_list = NULL; - gint i; - - DEBUG("Loading benchmark results from conf file %s", path); - - conf = g_key_file_new(); - - 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 **values; - bench_result *sbr; - - values = g_key_file_get_string_list(conf, benchmark, machines[i], NULL, - NULL); - sbr = bench_result_benchmarkconf(benchmark, machines[i], values); - result_list = g_slist_append(result_list, sbr); - - g_strfreev(values); - } - - g_strfreev(machines); - g_key_file_free(conf); - - return result_list; -} - struct append_machine_result_json_data { GSList **result_list; const gchar *benchmark_name; @@ -473,23 +437,18 @@ out: static gchar *find_benchmark_conf(void) { - const gchar *files[] = {"benchmark.json", "benchmark.conf", NULL}; const gchar *config_dir = g_get_user_config_dir(); - gint i; - - for (i = 0; files[i]; i++) { - gchar *path; + gchar *path; - path = g_build_filename(config_dir, "hardinfo", files[i], NULL); - if (g_file_test(path, G_FILE_TEST_EXISTS)) - return path; - g_free(path); + path = g_build_filename(config_dir, "hardinfo", "benchmark.json", NULL); + if (g_file_test(path, G_FILE_TEST_EXISTS)) + return path; + g_free(path); - path = g_build_filename(params.path_data, files[i], NULL); - if (g_file_test(path, G_FILE_TEST_EXISTS)) - return path; - g_free(path); - } + path = g_build_filename(params.path_data, "benchmark.json", NULL); + if (g_file_test(path, G_FILE_TEST_EXISTS)) + return path; + g_free(path); return NULL; } @@ -550,14 +509,8 @@ static gchar *benchmark_include_results_internal(bench_value this_machine_value, path = find_benchmark_conf(); if (path) { - if (g_str_has_suffix(path, ".json")) - result_list = benchmark_include_results_json( - path, this_machine_value, benchmark); - else if (g_str_has_suffix(path, ".conf")) - result_list = benchmark_include_results_conf( - path, this_machine_value, benchmark); - else - g_assert_not_reached(); + result_list = benchmark_include_results_json( + path, this_machine_value, benchmark); } /* this result */ @@ -901,13 +854,7 @@ static gchar *run_benchmark(gchar *name) strncpy(bench_results[i].user_note, params.bench_user_note, 255); - if (CHK_RESULT_FORMAT("conf")) { - bench_result *b = - bench_result_this_machine(name, bench_results[i]); - char *temp = bench_result_benchmarkconf_line(b); - bench_result_free(b); - return temp; - } else if (CHK_RESULT_FORMAT("shell")) { + if (CHK_RESULT_FORMAT("shell")) { bench_result *b = bench_result_this_machine(name, bench_results[i]); char *temp = bench_result_more_info_complete(b); diff --git a/modules/benchmark/bench_results.c b/modules/benchmark/bench_results.c index cd8cc6e8..40345aa5 100644 --- a/modules/benchmark/bench_results.c +++ b/modules/benchmark/bench_results.c @@ -379,161 +379,6 @@ bench_result *bench_result_benchmarkjson(const gchar *bench_name, return b; } -bench_result * -bench_result_benchmarkconf(const char *section, const char *key, char **values) -{ - bench_result *b = NULL; - char *s0, *s1, *s2; - int nx = 0, vl = 0; - float n, m; - - vl = g_strv_length(values); - - b = malloc(sizeof(bench_result)); - if (b) { - memset(b, 0, sizeof(bench_result)); - b->machine = bench_machine_new(); - b->name = strdup(section); - - if (vl >= 10) { /* the 11th could be empty */ - b->machine->mid = strdup(key); - /* 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]); - b->machine->cpu_config = strdup(values[5]); - b->machine->memory_kiB = strtoull(values[6], NULL, 10); - b->machine->processors = atoi(values[7]); - b->machine->cores = atoi(values[8]); - b->machine->threads = atoi(values[9]); - if (vl >= 11) - b->machine->ogl_renderer = strdup(values[10]); - if (vl >= 12) - b->machine->gpu_desc = strdup(values[11]); - if (vl >= 13) - b->machine->machine_data_version = atoi(values[12]); - if (vl >= 14) - b->machine->ptr_bits = atoi(values[13]); - if (vl >= 15) - b->machine->is_su_data = atoi(values[14]); - if (vl >= 16) - b->machine->memory_phys_MiB = strtoull(values[15], NULL, 10); - if (vl >= 17) - b->machine->ram_types = strdup(values[16]); - b->legacy = 0; - } else if (vl >= 2) { - b->bvalue.result = atof(values[0]); - b->legacy = 1; - - /* old old format has prefix before cpu name (ex: 4x Pentium...) */ - nx = nx_prefix(key); - if (nx > 0) { - b->machine->cpu_name = strdup(strchr(key, 'x') + 1); - b->machine->threads = nx; - } else { - b->machine->cpu_name = strdup(key); - b->machine->threads = 1; - } - - b->machine->cpu_config = strdup(values[1]); - /* new old format has cpu_config string with nx prefix */ - nx = nx_prefix(values[1]); - if (nx > 0) { - b->machine->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. - * "...@ 2.00GHz" -> 2000.0 */ - s0 = b->machine->cpu_name; - s2 = strstr(s0, "Hz"); - if (s2 && s2 > s0 + 2) { - m = 1; /* assume M */ - if (*(s2 - 1) == 'G') - m = 1000; - s1 = s2 - 2; - while (s1 > s0) { - if (!(isdigit(*s1) || *s1 == '.' || *s1 == ' ')) - break; - s1--; - } - - if (s1 > s0) { - n = atof(s1 + 1); - n *= m; - - 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); - b->machine->cpu_config = s1; - } else { - free(s1); - } - } - } - - /* old results only give threads */ - b->machine->processors = -1; - b->machine->cores = -1; - - /* clean the old result's CPU model name if it was probably an x86 */ - if (cpu_name_needs_cleanup(b->machine->cpu_name)) - nice_name_x86_cpuid_model_string(b->machine->cpu_name); - } - - b->machine->cpu_config = - cpu_config_retranslate(b->machine->cpu_config, 0, 1); - if (b->machine->board != NULL && strlen(b->machine->board) == 0) { - free(b->machine->board); - b->machine->board = NULL; - } - if (b->machine->cpu_desc != NULL && strlen(b->machine->cpu_desc) == 0) { - free(b->machine->cpu_desc); - b->machine->cpu_desc = NULL; - } - gen_machine_id(b->machine); - } - return b; -} - -char *bench_result_benchmarkconf_line(bench_result *b) -{ - char *cpu_config = cpu_config_retranslate(b->machine->cpu_config, 1, 0); - char *bv = bench_value_to_str(b->bvalue); - -#define prep_str(s) \ - (s ? (char *)auto_free(gg_key_file_parse_string_as_value(s, '|')) : "") - char *ret = g_strdup_printf( - "%s=%s|%d|%s|%s|%s|%s|%" PRId64 "|%d|%d|%d|%s|%s|%d|%d|%d|%" PRId64 - "|%s\n", - b->machine->mid, bv, b->bvalue.threads_used, - prep_str(b->machine->board), prep_str(b->machine->cpu_name), - prep_str(b->machine->cpu_desc), prep_str(cpu_config), - b->machine->memory_kiB, b->machine->processors, b->machine->cores, - b->machine->threads, prep_str(b->machine->ogl_renderer), - prep_str(b->machine->gpu_desc), - b->machine->machine_data_version, // [12] - b->machine->ptr_bits, // [13] - b->machine->is_su_data, // [14] - b->machine->memory_phys_MiB, // [15] - b->machine->ram_types // [16] - ); - - free(cpu_config); - free(bv); - return ret; -} - static char *bench_result_more_info_less(bench_result *b) { char *memory = NULL; |