[PATCH 10/11] fwts: scale cpu benchmark results to one second
Jeremy Kerr
jk at ozlabs.org
Thu May 21 09:34:27 UTC 2015
Signed-off-by: Jeremy Kerr <jk at ozlabs.org>
---
src/lib/src/fwts_cpu.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/src/lib/src/fwts_cpu.c b/src/lib/src/fwts_cpu.c
index 743de63..d7793b7 100644
--- a/src/lib/src/fwts_cpu.c
+++ b/src/lib/src/fwts_cpu.c
@@ -378,6 +378,7 @@ int fwts_cpu_benchmark(
fwts_cpu_benchmark_result tmp;
cpu_set_t mask, oldset;
int perfctr, ncpus, rc;
+ double duration_sec;
static bool warned;
bool perf_ok;
@@ -445,12 +446,15 @@ int fwts_cpu_benchmark(
return FWTS_ERROR;
}
+ duration_sec = duration.tv_sec +
+ ((1.0 * duration.tv_usec) / 1000000.0);
+
+ tmp.loops = (1.0 * tmp.loops) / duration_sec;
+
if (perf_ok) {
rc = perf_read_counter(perfctr, &perfctr_result);
if (rc == FWTS_OK) {
- tmp.cycles = perfctr_result /
- ((1.0 * duration.tv_usec / 1000000) +
- duration.tv_sec);
+ tmp.cycles = (1.0 * perfctr_result) / duration_sec;
tmp.cycles_valid = true;
} else {
fwts_log_warning(fw, "failed to read perf counters");
More information about the fwts-devel
mailing list