diff mbox

[i-g-t,07/11] trace.pl: Move min/max timestamp lookup to last loop

Message ID 20180306124315.30208-8-tvrtko.ursulin@linux.intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Tvrtko Ursulin March 6, 2018, 12:43 p.m. UTC
From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>

It makes sense to fetch the min and max timestamp only after the
last sort of the array.

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Cc: John Harrison <John.C.Harrison@intel.com>
---
 scripts/trace.pl | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

Comments

Lionel Landwerlin April 18, 2018, 4:56 p.m. UTC | #1
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>

On 06/03/18 04:43, Tvrtko Ursulin wrote:
> From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
>
> It makes sense to fetch the min and max timestamp only after the
> last sort of the array.
>
> Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
> Cc: John Harrison <John.C.Harrison@intel.com>
> ---
>   scripts/trace.pl | 11 ++++++-----
>   1 file changed, 6 insertions(+), 5 deletions(-)
>
> diff --git a/scripts/trace.pl b/scripts/trace.pl
> index d49d25d6c1ca..27b39efcebbd 100755
> --- a/scripts/trace.pl
> +++ b/scripts/trace.pl
> @@ -531,8 +531,6 @@ foreach my $key (keys %db) {
>   # GPU time accounting
>   my (%running, %runnable, %queued, %batch_avg, %batch_total_avg, %batch_count);
>   my (%submit_avg, %execute_avg, %ctxsave_avg);
> -my $last_ts = 0;
> -my $first_ts;
>   
>   sub sortStart {
>   	my $as = $db{$a}->{'start'};
> @@ -554,9 +552,6 @@ foreach my $key (@sorted_keys) {
>   	my $ring = $db{$key}->{'ring'};
>   	my $end = $db{$key}->{'end'};
>   
> -	$first_ts = $db{$key}->{'queue'} if not defined $first_ts or $db{$key}->{'queue'} < $first_ts;
> -	$last_ts = $end if $end > $last_ts;
> -
>   	# correct duration of merged batches
>   	if ($correct_durations and exists $db{$key}->{'no-end'}) {
>   		my $ctx = $db{$key}->{'ctx'};
> @@ -584,12 +579,18 @@ foreach my $key (@sorted_keys) {
>   
>   @sorted_keys = sort sortStart keys %db if $re_sort;
>   
> +my $last_ts = 0;
> +my $first_ts;
> +
>   foreach my $key (@sorted_keys) {
>   	my $ring = $db{$key}->{'ring'};
>   	my $end = $db{$key}->{'end'};
>   	my $start = $db{$key}->{'start'};
>   	my $notify = $db{$key}->{'notify'};
>   
> +	$first_ts = $db{$key}->{'queue'} if not defined $first_ts or $db{$key}->{'queue'} < $first_ts;
> +	$last_ts = $end if $end > $last_ts;
> +
>   	$db{$key}->{'context-complete-delay'} = $end - $notify;
>   	$db{$key}->{'execute-delay'} = $start - $db{$key}->{'submit'};
>   	$db{$key}->{'submit-delay'} = $db{$key}->{'submit'} - $db{$key}->{'queue'};
diff mbox

Patch

diff --git a/scripts/trace.pl b/scripts/trace.pl
index d49d25d6c1ca..27b39efcebbd 100755
--- a/scripts/trace.pl
+++ b/scripts/trace.pl
@@ -531,8 +531,6 @@  foreach my $key (keys %db) {
 # GPU time accounting
 my (%running, %runnable, %queued, %batch_avg, %batch_total_avg, %batch_count);
 my (%submit_avg, %execute_avg, %ctxsave_avg);
-my $last_ts = 0;
-my $first_ts;
 
 sub sortStart {
 	my $as = $db{$a}->{'start'};
@@ -554,9 +552,6 @@  foreach my $key (@sorted_keys) {
 	my $ring = $db{$key}->{'ring'};
 	my $end = $db{$key}->{'end'};
 
-	$first_ts = $db{$key}->{'queue'} if not defined $first_ts or $db{$key}->{'queue'} < $first_ts;
-	$last_ts = $end if $end > $last_ts;
-
 	# correct duration of merged batches
 	if ($correct_durations and exists $db{$key}->{'no-end'}) {
 		my $ctx = $db{$key}->{'ctx'};
@@ -584,12 +579,18 @@  foreach my $key (@sorted_keys) {
 
 @sorted_keys = sort sortStart keys %db if $re_sort;
 
+my $last_ts = 0;
+my $first_ts;
+
 foreach my $key (@sorted_keys) {
 	my $ring = $db{$key}->{'ring'};
 	my $end = $db{$key}->{'end'};
 	my $start = $db{$key}->{'start'};
 	my $notify = $db{$key}->{'notify'};
 
+	$first_ts = $db{$key}->{'queue'} if not defined $first_ts or $db{$key}->{'queue'} < $first_ts;
+	$last_ts = $end if $end > $last_ts;
+
 	$db{$key}->{'context-complete-delay'} = $end - $notify;
 	$db{$key}->{'execute-delay'} = $start - $db{$key}->{'submit'};
 	$db{$key}->{'submit-delay'} = $db{$key}->{'submit'} - $db{$key}->{'queue'};