[Intel-gfx] [PATCH i-g-t 1/9] trace.pl: Improve time axis labels

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


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

It is possible to customize the axis display so change it to display
timestamps in seconds on the major axis (with six decimal spaces) and
relative millisecond offsets on the minor axis.

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
Suggested-by: Chris Wilson <chris at chris-wilson.co.uk>
Cc: Chris Wilson <chris at chris-wilson.co.uk>
Cc: John Harrison <John.C.Harrison at Intel.com>
---
 scripts/trace.pl | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)

diff --git a/scripts/trace.pl b/scripts/trace.pl
index fc1713e4f9a7..89491125490d 100755
--- a/scripts/trace.pl
+++ b/scripts/trace.pl
@@ -1000,6 +1000,37 @@ $first_ts = ts($first_ts);
 print <<ENDHTML;
   ]);
 
+  var last_major_ms;
+
+  function majorAxis(date, scale, step) {
+	var s = date / 1000;
+
+	last_major_ms = date;
+
+	if (scale == 'millisecond')
+		return s.toFixed(6) + "s";
+	else if (scale == 'second')
+		return s.toFixed(3) + "s";
+	else
+		return s.toFixed(0) + "s";
+  }
+
+  function minorAxis(date, scale, step) {
+	var ms = date;
+
+	ms -= last_major_ms;
+
+	if (ms < 0)
+		return '';
+
+	if (scale == 'millisecond')
+		return "+" + ms.toFixed(3) + "ms";
+	else if (scale == 'second')
+		return ms.toFixed(3) + "s";
+	else
+		return ms.toFixed(0) + "s";
+  }
+
   // Configuration for the Timeline
   var options = { groupOrder: 'content',
 		  horizontalScroll: true,
@@ -1007,6 +1038,7 @@ print <<ENDHTML;
 		  stackSubgroups: false,
 		  zoomKey: 'ctrlKey',
 		  orientation: 'top',
+		  format: { majorLabels: majorAxis, minorLabels: minorAxis },
 		  start: '$first_ts',
 		  end: '$end_ts'};
 
-- 
2.17.1



More information about the Intel-gfx mailing list