From 3cc8f957f1c443f012b292dbb5d81acb59dffb25 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Sun, 20 Dec 2015 15:18:56 +0000 Subject: benchmarks/gem_latency: Measure CPU usage Try and gauge the amount of CPU time used for each dispatch/wait cycle. Signed-off-by: Chris Wilson --- benchmarks/gem_latency.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'benchmarks/gem_latency.c') diff --git a/benchmarks/gem_latency.c b/benchmarks/gem_latency.c index 6108a9d6..65065b16 100644 --- a/benchmarks/gem_latency.c +++ b/benchmarks/gem_latency.c @@ -40,6 +40,7 @@ #include #include #include +#include #include "drm.h" static int done; @@ -347,6 +348,12 @@ static double l_estimate(igt_stats_t *stats) return igt_stats_get_mean(stats); } +static double cpu_time(const struct rusage *r) +{ + return 10e6*(r->ru_utime.tv_sec + r->ru_stime.tv_sec) + + (r->ru_utime.tv_usec + r->ru_stime.tv_usec); +} + #define CONTEXT 1 #define REALTIME 2 static int run(int seconds, @@ -359,6 +366,7 @@ static int run(int seconds, pthread_attr_t attr; struct producer *p; igt_stats_t platency, latency, dispatch; + struct rusage rused; uint32_t nop_batch; uint32_t workload_batch; uint32_t scratch; @@ -458,12 +466,16 @@ static int run(int seconds, } } + getrusage(RUSAGE_SELF, &rused); + switch ((flags >> 8) & 0xf) { default: - printf("%d/%d: %7.3fus %7.3fus %7.3fus\n", complete, nrun, + printf("%d/%d: %7.3fus %7.3fus %7.3fus %7.3fus\n", + complete, nrun, CYCLES_TO_US(l_estimate(&dispatch)), CYCLES_TO_US(l_estimate(&latency)), - CYCLES_TO_US(l_estimate(&platency))); + CYCLES_TO_US(l_estimate(&platency)), + cpu_time(&rused) / complete); break; case 1: printf("%f\n", CYCLES_TO_US(l_estimate(&dispatch))); @@ -474,6 +486,9 @@ static int run(int seconds, case 3: printf("%f\n", CYCLES_TO_US(l_estimate(&platency))); break; + case 4: + printf("%f\n", cpu_time(&rused) / complete); + break; } return 0; -- cgit v1.2.3