benchmarks/gem_latency: Add time control

Allow the user to choose a time to run for, default 10s

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
This commit is contained in:
Chris Wilson 2015-12-19 11:36:37 +00:00
parent 2ef368acfa
commit e37a4c8092

View File

@ -279,7 +279,8 @@ static double l_estimate(igt_stats_t *stats)
} }
#define CONTEXT 1 #define CONTEXT 1
static int run(int nproducers, static int run(int seconds,
int nproducers,
int nconsumers, int nconsumers,
int nop, int nop,
int workload, int workload,
@ -336,7 +337,7 @@ static int run(int nproducers,
for (n = 0; n < nproducers; n++) for (n = 0; n < nproducers; n++)
pthread_create(&p[n].thread, NULL, producer, &p[n]); pthread_create(&p[n].thread, NULL, producer, &p[n]);
sleep(10); sleep(seconds);
done = true; done = true;
nrun = complete = 0; nrun = complete = 0;
@ -369,6 +370,7 @@ static int run(int nproducers,
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
int time = 10;
int producers = 1; int producers = 1;
int consumers = 0; int consumers = 0;
int nop = 0; int nop = 0;
@ -376,7 +378,7 @@ int main(int argc, char **argv)
unsigned flags = 0; unsigned flags = 0;
int c; int c;
while ((c = getopt(argc, argv, "p:c:n:w:s")) != -1) { while ((c = getopt(argc, argv, "p:c:n:w:t:s")) != -1) {
switch (c) { switch (c) {
case 'p': case 'p':
/* How many threads generate work? */ /* How many threads generate work? */
@ -406,6 +408,13 @@ int main(int argc, char **argv)
workload = 1; workload = 1;
break; break;
case 't':
/* How long to run the benchmark for (seconds) */
time = atoi(optarg);
if (time < 1)
time = 1;
break;
case 's': case 's':
/* Assign each producer to its own context, adding /* Assign each producer to its own context, adding
* context switching into the mix (e.g. execlists * context switching into the mix (e.g. execlists
@ -421,5 +430,5 @@ int main(int argc, char **argv)
} }
} }
return run(producers, consumers, nop, workload, flags); return run(time, producers, consumers, nop, workload, flags);
} }