diff mbox series

[i-g-t,03/10] gem_wsim: Show workload timing stats

Message ID 20200617160120.16555-4-tvrtko.ursulin@linux.intel.com (mailing list archive)
State New, archived
Headers show
Series gem_wsim improvements | expand

Commit Message

Tvrtko Ursulin June 17, 2020, 4:01 p.m. UTC
From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>

Show average/min/max workload iteration and dropped period stats when 'p'
command is used.

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
---
 benchmarks/gem_wsim.c | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

Comments

Chris Wilson June 17, 2020, 4:58 p.m. UTC | #1
Quoting Tvrtko Ursulin (2020-06-17 17:01:13)
> From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
> 
> Show average/min/max workload iteration and dropped period stats when 'p'
> command is used.
> 
> Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
> ---
>  benchmarks/gem_wsim.c | 19 +++++++++++++++----
>  1 file changed, 15 insertions(+), 4 deletions(-)
> 
> diff --git a/benchmarks/gem_wsim.c b/benchmarks/gem_wsim.c
> index 9e5bfe6a36d4..60982cb73ba7 100644
> --- a/benchmarks/gem_wsim.c
> +++ b/benchmarks/gem_wsim.c
> @@ -2101,7 +2101,8 @@ static void *run_workload(void *data)
>         struct w_step *w;
>         int throttle = -1;
>         int qd_throttle = -1;
> -       int count;
> +       int count, missed = 0;
> +       unsigned long time_tot = 0, time_min = ULONG_MAX, time_max = 0;
>         int i;
>  
>         clock_gettime(CLOCK_MONOTONIC, &t_start);
> @@ -2121,12 +2122,19 @@ static void *run_workload(void *data)
>                                 do_sleep = w->delay;
>                         } else if (w->type == PERIOD) {
>                                 struct timespec now;
> +                               int elapsed;
>  
>                                 clock_gettime(CLOCK_MONOTONIC, &now);
> -                               do_sleep = w->period -
> -                                          elapsed_us(&wrk->repeat_start, &now);
> +                               elapsed = elapsed_us(&wrk->repeat_start, &now);
> +                               do_sleep = w->period - elapsed;
> +                               time_tot += elapsed;
> +                               if (elapsed < time_min)
> +                                       time_min = elapsed;
> +                               if (elapsed > time_max)
> +                                       time_max = elapsed;

Keep the running average?

>                                 if (do_sleep < 0) {
> -                                       if (verbose > 1)
> +                                       missed++;
> +                                       if (verbose > 2)
>                                                 printf("%u: Dropped period @ %u/%u (%dus late)!\n",
>                                                        wrk->id, count, i, do_sleep);
>                                         continue;
> @@ -2280,6 +2288,9 @@ static void *run_workload(void *data)
>                 printf("%c%u: %.3fs elapsed (%d cycles, %.3f workloads/s).",
>                        wrk->background ? ' ' : '*', wrk->id,
>                        t, count, count / t);
> +               if (time_tot)
> +                       printf(" Time avg/min/max=%lu/%lu/%luus; %u missed.",
> +                              time_tot / count, time_min, time_max, missed);
>                 putchar('\n');
>         }
>  
> -- 
> 2.20.1
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx
>
Tvrtko Ursulin June 18, 2020, 7:46 a.m. UTC | #2
On 17/06/2020 17:58, Chris Wilson wrote:
> Quoting Tvrtko Ursulin (2020-06-17 17:01:13)
>> From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
>>
>> Show average/min/max workload iteration and dropped period stats when 'p'
>> command is used.
>>
>> Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
>> ---
>>   benchmarks/gem_wsim.c | 19 +++++++++++++++----
>>   1 file changed, 15 insertions(+), 4 deletions(-)
>>
>> diff --git a/benchmarks/gem_wsim.c b/benchmarks/gem_wsim.c
>> index 9e5bfe6a36d4..60982cb73ba7 100644
>> --- a/benchmarks/gem_wsim.c
>> +++ b/benchmarks/gem_wsim.c
>> @@ -2101,7 +2101,8 @@ static void *run_workload(void *data)
>>          struct w_step *w;
>>          int throttle = -1;
>>          int qd_throttle = -1;
>> -       int count;
>> +       int count, missed = 0;
>> +       unsigned long time_tot = 0, time_min = ULONG_MAX, time_max = 0;
>>          int i;
>>   
>>          clock_gettime(CLOCK_MONOTONIC, &t_start);
>> @@ -2121,12 +2122,19 @@ static void *run_workload(void *data)
>>                                  do_sleep = w->delay;
>>                          } else if (w->type == PERIOD) {
>>                                  struct timespec now;
>> +                               int elapsed;
>>   
>>                                  clock_gettime(CLOCK_MONOTONIC, &now);
>> -                               do_sleep = w->period -
>> -                                          elapsed_us(&wrk->repeat_start, &now);
>> +                               elapsed = elapsed_us(&wrk->repeat_start, &now);
>> +                               do_sleep = w->period - elapsed;
>> +                               time_tot += elapsed;
>> +                               if (elapsed < time_min)
>> +                                       time_min = elapsed;
>> +                               if (elapsed > time_max)
>> +                                       time_max = elapsed;
> 
> Keep the running average?

Could do but why? I already have the count so adding up total elapsed 
frame time sound easiest.

Regards,

Tvrtko

> 
>>                                  if (do_sleep < 0) {
>> -                                       if (verbose > 1)
>> +                                       missed++;
>> +                                       if (verbose > 2)
>>                                                  printf("%u: Dropped period @ %u/%u (%dus late)!\n",
>>                                                         wrk->id, count, i, do_sleep);
>>                                          continue;
>> @@ -2280,6 +2288,9 @@ static void *run_workload(void *data)
>>                  printf("%c%u: %.3fs elapsed (%d cycles, %.3f workloads/s).",
>>                         wrk->background ? ' ' : '*', wrk->id,
>>                         t, count, count / t);
>> +               if (time_tot)
>> +                       printf(" Time avg/min/max=%lu/%lu/%luus; %u missed.",
>> +                              time_tot / count, time_min, time_max, missed);
>>                  putchar('\n');
>>          }
>>   
>> -- 
>> 2.20.1
>>
>> _______________________________________________
>> Intel-gfx mailing list
>> Intel-gfx@lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/intel-gfx
>>
Chris Wilson June 18, 2020, 7:57 a.m. UTC | #3
Quoting Tvrtko Ursulin (2020-06-18 08:46:18)
> 
> On 17/06/2020 17:58, Chris Wilson wrote:
> > Quoting Tvrtko Ursulin (2020-06-17 17:01:13)
> >> From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
> >>
> >> Show average/min/max workload iteration and dropped period stats when 'p'
> >> command is used.
> >>
> >> Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
> >> ---
> >>   benchmarks/gem_wsim.c | 19 +++++++++++++++----
> >>   1 file changed, 15 insertions(+), 4 deletions(-)
> >>
> >> diff --git a/benchmarks/gem_wsim.c b/benchmarks/gem_wsim.c
> >> index 9e5bfe6a36d4..60982cb73ba7 100644
> >> --- a/benchmarks/gem_wsim.c
> >> +++ b/benchmarks/gem_wsim.c
> >> @@ -2101,7 +2101,8 @@ static void *run_workload(void *data)
> >>          struct w_step *w;
> >>          int throttle = -1;
> >>          int qd_throttle = -1;
> >> -       int count;
> >> +       int count, missed = 0;
> >> +       unsigned long time_tot = 0, time_min = ULONG_MAX, time_max = 0;
> >>          int i;
> >>   
> >>          clock_gettime(CLOCK_MONOTONIC, &t_start);
> >> @@ -2121,12 +2122,19 @@ static void *run_workload(void *data)
> >>                                  do_sleep = w->delay;
> >>                          } else if (w->type == PERIOD) {
> >>                                  struct timespec now;
> >> +                               int elapsed;
> >>   
> >>                                  clock_gettime(CLOCK_MONOTONIC, &now);
> >> -                               do_sleep = w->period -
> >> -                                          elapsed_us(&wrk->repeat_start, &now);
> >> +                               elapsed = elapsed_us(&wrk->repeat_start, &now);
> >> +                               do_sleep = w->period - elapsed;
> >> +                               time_tot += elapsed;
> >> +                               if (elapsed < time_min)
> >> +                                       time_min = elapsed;
> >> +                               if (elapsed > time_max)
> >> +                                       time_max = elapsed;
> > 
> > Keep the running average?
> 
> Could do but why? I already have the count so adding up total elapsed 
> frame time sound easiest.

Because I was blind and didn't see it in the printf.
-Chris
diff mbox series

Patch

diff --git a/benchmarks/gem_wsim.c b/benchmarks/gem_wsim.c
index 9e5bfe6a36d4..60982cb73ba7 100644
--- a/benchmarks/gem_wsim.c
+++ b/benchmarks/gem_wsim.c
@@ -2101,7 +2101,8 @@  static void *run_workload(void *data)
 	struct w_step *w;
 	int throttle = -1;
 	int qd_throttle = -1;
-	int count;
+	int count, missed = 0;
+	unsigned long time_tot = 0, time_min = ULONG_MAX, time_max = 0;
 	int i;
 
 	clock_gettime(CLOCK_MONOTONIC, &t_start);
@@ -2121,12 +2122,19 @@  static void *run_workload(void *data)
 				do_sleep = w->delay;
 			} else if (w->type == PERIOD) {
 				struct timespec now;
+				int elapsed;
 
 				clock_gettime(CLOCK_MONOTONIC, &now);
-				do_sleep = w->period -
-					   elapsed_us(&wrk->repeat_start, &now);
+				elapsed = elapsed_us(&wrk->repeat_start, &now);
+				do_sleep = w->period - elapsed;
+				time_tot += elapsed;
+				if (elapsed < time_min)
+					time_min = elapsed;
+				if (elapsed > time_max)
+					time_max = elapsed;
 				if (do_sleep < 0) {
-					if (verbose > 1)
+					missed++;
+					if (verbose > 2)
 						printf("%u: Dropped period @ %u/%u (%dus late)!\n",
 						       wrk->id, count, i, do_sleep);
 					continue;
@@ -2280,6 +2288,9 @@  static void *run_workload(void *data)
 		printf("%c%u: %.3fs elapsed (%d cycles, %.3f workloads/s).",
 		       wrk->background ? ' ' : '*', wrk->id,
 		       t, count, count / t);
+		if (time_tot)
+			printf(" Time avg/min/max=%lu/%lu/%luus; %u missed.",
+			       time_tot / count, time_min, time_max, missed);
 		putchar('\n');
 	}