aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBurt P <pburt0@gmail.com>2017-08-14 01:37:27 -0500
committerLeandro A. F. Pereira <leandro@hardinfo.org>2017-08-21 05:47:00 -0700
commit726b9bf46a6130a86be57c9d1bd4d7b975c5f09d (patch)
tree80d119c0b2b8ec2cda5e88605f645098fc355393
parent425c944136d99eeb8ce69ee2c7a54695171ff8d2 (diff)
bench_results: fix cpu clock from id string
Old versions of hardinfo used current frequency instead of max frequency. If the cpu id string had a clock rate in it, and it is significantly more than thre reported frequency in the benchmark result, use that. This feature exists in an earlier commit but it was broken. Signed-off-by: Burt P <pburt0@gmail.com>
-rw-r--r--modules/benchmark/bench_results.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/modules/benchmark/bench_results.c b/modules/benchmark/bench_results.c
index cef26e73..57cb56ea 100644
--- a/modules/benchmark/bench_results.c
+++ b/modules/benchmark/bench_results.c
@@ -96,7 +96,6 @@ static gen_machine_id(simple_machine *m) {
}
}
-
simple_machine *simple_machine_new() {
simple_machine *m = NULL;
m = malloc(sizeof(simple_machine));
@@ -161,7 +160,7 @@ bench_result *bench_result_this_machine(const char *bench_name, float result, in
static int nx_prefix(const char *str) {
char *s, *x;
if (str != NULL) {
- s = str;
+ s = (char*)str;
x = strchr(str, 'x');
if (x && x-s >= 1) {
while(s != x) {
@@ -231,18 +230,18 @@ bench_result *bench_result_benchmarkconf(const char *section, const char *key, c
* "...@ 2.00GHz" -> 2000.0 */
s0 = b->machine->cpu_name;
s2 = strstr(s0, "Hz");
- if (s2 && s2 != s0) {
- s1 = s2 - 1;
+ 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 == ' ')
+ if (!( isdigit(*s1) || *s1 == '.' || *s1 == ' '))
break;
s1--;
}
if (s1 > s0) {
- m = 0; /* assume M */
- if (*(s2-1) == 'G')
- m = 1000;
n = atof(s1+1);
n *= m;