[Intel-gfx] [PATCH i-g-t 2/9] trace.pl: Scale timeline for better precision

Tvrtko Ursulin tursulin at ursulin.net
Thu Jul 12 10:59:51 UTC 2018


From: Tvrtko Ursulin <tvrtko.ursulin at intel.com>

vis library has a limited precision compared to our trace data which
prevents zooming into the timeline and seeing the fine detail.

Scale the HTML view by a thousand to work around it.

v2: Rebase for time axis changes.

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
Suggested-by: John Harrison <John.C.Harrison at Intel.com>
Cc: John Harrison <John.C.Harrison at Intel.com>
Reviewed-by: John Harrison <John.C.Harrison at Intel.com> # v1
---
 scripts/trace.pl | 46 +++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 43 insertions(+), 3 deletions(-)

diff --git a/scripts/trace.pl b/scripts/trace.pl
index 89491125490d..726c90d44547 100755
--- a/scripts/trace.pl
+++ b/scripts/trace.pl
@@ -40,6 +40,7 @@ my $trace = 0;
 my $avg_delay_stats = 0;
 my $gpu_timeline = 0;
 my $colour_contexts = 0;
+my $no_timeline_scaling = 0;
 
 my @args;
 
@@ -281,6 +282,18 @@ sub arg_colour_contexts
 	return @_;
 }
 
+sub arg_no_timeline_scaling
+{
+	return unless scalar(@_);
+
+	if ($_[0] eq '--no-timeline-scaling') {
+		shift @_;
+		$no_timeline_scaling = 1;
+	}
+
+	return @_;
+}
+
 @args = @ARGV;
 while (@args) {
 	my $left = scalar(@args);
@@ -296,6 +309,7 @@ while (@args) {
 	@args = arg_ignore_ring(@args);
 	@args = arg_skip_box(@args);
 	@args = arg_colour_contexts(@args);
+	@args = arg_no_timeline_scaling(@args);
 
 	last if $left == scalar(@args);
 }
@@ -334,6 +348,8 @@ sub ts
 	my ($us) = @_;
 	my ($y, $mo, $d, $h, $m, $s);
 
+	$us *= 1000 unless $no_timeline_scaling;
+
 	$s = int($us / 1000000);
 	$us = $us % 1000000;
 
@@ -1001,11 +1017,28 @@ print <<ENDHTML;
   ]);
 
   var last_major_ms;
+ENDHTML
+
+if ($html) {
+	if ($no_timeline_scaling) {
+		say "  timeDiv = 1;";
+	} else {
+		say "  timeDiv = 1000;";
+	}
+}
 
+print <<ENDHTML;
   function majorAxis(date, scale, step) {
-	var s = date / 1000;
+	var s = date / 1000 / timeDiv;
+
+	last_major_ms = date / timeDiv;
 
-	last_major_ms = date;
+	if (timeDiv == 1000) {
+		if (scale == 'second')
+			scale = 'millisecond';
+		else if (scale == 'minute')
+			scale = 'second'
+	}
 
 	if (scale == 'millisecond')
 		return s.toFixed(6) + "s";
@@ -1016,13 +1049,20 @@ print <<ENDHTML;
   }
 
   function minorAxis(date, scale, step) {
-	var ms = date;
+	var ms = date / timeDiv;
 
 	ms -= last_major_ms;
 
 	if (ms < 0)
 		return '';
 
+	if (timeDiv > 1) {
+		if (scale == 'second')
+			scale = 'millisecond';
+		else if (scale == 'minute')
+			scale = 'second';
+	}
+
 	if (scale == 'millisecond')
 		return "+" + ms.toFixed(3) + "ms";
 	else if (scale == 'second')
-- 
2.17.1



More information about the Intel-gfx mailing list