diff options
| author | Burt P <pburt0@gmail.com> | 2019-07-09 18:21:36 -0500 | 
|---|---|---|
| committer | Leandro A. F. Pereira <leandro@hardinfo.org> | 2019-07-10 12:26:24 -0700 | 
| commit | 201513a63d65596739a05dbc051916a284194715 (patch) | |
| tree | 2e3858099338a57802e6365b718ac7f1b2580873 /modules | |
| parent | 314208fd25cbb3f9705d4c2340118b3d57354c61 (diff) | |
benchmark: add extra fields to result for revision and information
* add an integer revision field
* add an extra information string field
* zlib benchmark: new revision[1] is 2, so that old results are obviously old,
  and now the zlib version string will be stored in extra information.
[1] as of 6a8e19a14305079b03e45eeb0580a45104f300dd
Signed-off-by: Burt P <pburt0@gmail.com>
Diffstat (limited to 'modules')
| -rw-r--r-- | modules/benchmark.c | 13 | ||||
| -rw-r--r-- | modules/benchmark/bench_results.c | 16 | ||||
| -rw-r--r-- | modules/benchmark/zlib.c | 2 | 
3 files changed, 27 insertions, 4 deletions
| diff --git a/modules/benchmark.c b/modules/benchmark.c index 64f55e1f..efff08f1 100644 --- a/modules/benchmark.c +++ b/modules/benchmark.c @@ -44,20 +44,27 @@ static gchar *benchmark_include_results(bench_value result, const gchar * benchm  static gboolean sending_benchmark_results = FALSE;  char *bench_value_to_str(bench_value r) { -    return g_strdup_printf("%lf; %lf; %d", r.result, r.elapsed_time, r.threads_used); +    return g_strdup_printf("%lf; %lf; %d; %d; %s", r.result, r.elapsed_time, r.threads_used, r.revision, r.extra);  }  bench_value bench_value_from_str(const char* str) {      bench_value ret = EMPTY_BENCH_VALUE;      double r, e; -    int t, c; +    int t, c, v; +    char extra[256];      if (str) { -        c = sscanf(str, "%lf; %lf; %d", &r, &e, &t); +        c = sscanf(str, "%lf; %lf; %d; %d; %255[^\r\n;|]", &r, &e, &t, &v, extra);          if (c >= 3) {              ret.result = r;              ret.elapsed_time = e;              ret.threads_used = t;          } +        if (c >= 4) { +            ret.revision = v; +        } +        if (c >= 5) { +            strcpy(ret.extra, extra); +        }      }      return ret;  } diff --git a/modules/benchmark/bench_results.c b/modules/benchmark/bench_results.c index a4335151..3609a5dd 100644 --- a/modules/benchmark/bench_results.c +++ b/modules/benchmark/bench_results.c @@ -374,10 +374,15 @@ static char *bench_result_more_info_less(bench_result *b) {          (b->machine->memory_kiB > 0)          ? g_strdup_printf("%d %s", b->machine->memory_kiB, _("kiB") )          : g_strdup(_(unk) ); +    char bench_str[256] = ""; +    if (b->bvalue.revision >= 0) +        snprintf(bench_str, 127, "%d", b->bvalue.revision);      char *ret = g_strdup_printf("[%s]\n"          /* threads */   "%s=%d\n"          /* elapsed */   "%s=%0.4f %s\n" +                        "%s=%s\n" +                        "%s=%s\n"          /* legacy */    "%s=%s\n"                          "[%s]\n"          /* board */     "%s=%s\n" @@ -391,6 +396,8 @@ static char *bench_result_more_info_less(bench_result *b) {                          _("Benchmark Result"),                          _("Threads"), b->bvalue.threads_used,                          _("Elapsed Time"), b->bvalue.elapsed_time, _("seconds"), +                        *bench_str ? _("Revision") : _("#Revision"), bench_str, +                        *b->bvalue.extra ? _("Extra Information") : _("#Extra"), b->bvalue.extra,                          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"), @@ -408,11 +415,17 @@ static char *bench_result_more_info_less(bench_result *b) {  }  static char *bench_result_more_info_complete(bench_result *b) { +    char bench_str[256] = ""; +    strncpy(bench_str, b->name, 127); +    if (b->bvalue.revision >= 0) +        snprintf(bench_str + strlen(bench_str), 127, " (r%d)", b->bvalue.revision); +      return g_strdup_printf("[%s]\n"          /* bench name */"%s=%s\n"          /* threads */   "%s=%d\n"          /* result */    "%s=%0.2f\n"          /* elapsed */   "%s=%0.4f %s\n" +                        "%s=%s\n"          /* legacy */    "%s=%s\n"                          "[%s]\n"          /* board */     "%s=%s\n" @@ -427,10 +440,11 @@ static char *bench_result_more_info_complete(bench_result *b) {          /* mid */       "%s=%s\n"          /* cfg_val */   "%s=%.2f\n",                          _("Benchmark Result"), -                        _("Benchmark"), b->name, +                        _("Benchmark"), bench_str,                          _("Threads"), b->bvalue.threads_used,                          _("Result"), b->bvalue.result,                          _("Elapsed Time"), b->bvalue.elapsed_time, _("seconds"), +                        *b->bvalue.extra ? _("Extra Information") : _("#Extra"), b->bvalue.extra,                          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"), diff --git a/modules/benchmark/zlib.c b/modules/benchmark/zlib.c index 5d7b4d4f..ce6a0048 100644 --- a/modules/benchmark/zlib.c +++ b/modules/benchmark/zlib.c @@ -93,6 +93,8 @@ benchmark_zlib(void)      r = benchmark_crunch_for(CRUNCH_TIME, 0, zlib_for, data);      r.result /= 100; +    r.revision = 2; +    snprintf(r.extra, 255, "zlib %s (built against: %s)", zlib_version, ZLIB_VERSION);      bench_results[BENCHMARK_ZLIB] = r;      g_free(data); | 
