diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2015-12-20 15:18:56 +0000 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2015-12-20 21:22:35 +0000 |
commit | 3cc8f957f1c443f012b292dbb5d81acb59dffb25 (patch) | |
tree | c3bba42baccfef12351dc24678c547956d5a77d8 /benchmarks | |
parent | a91ee853b1a1e733c0d4e291d8fc3008a9ac232f (diff) |
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 <chris@chris-wilson.co.uk>
Diffstat (limited to 'benchmarks')
-rw-r--r-- | benchmarks/gem_latency.c | 19 |
1 files changed, 17 insertions, 2 deletions
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 <sys/stat.h> #include <sys/ioctl.h> #include <sys/time.h> +#include <sys/resource.h> #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; |