[igt-dev] [PATCH i-g-t v2 1/9] trace.pl: Improve time axis labels

Tvrtko Ursulin tursulin at ursulin.net
Fri Jul 13 09:55:37 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
millisecond offsets on the minor axis.

v2:
 * Give up on broken relative timestamps.

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 | 37 +++++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)

diff --git a/scripts/trace.pl b/scripts/trace.pl
index fc1713e4f9a7..41f10749a153 100755
--- a/scripts/trace.pl
+++ b/scripts/trace.pl
@@ -1000,6 +1000,42 @@ $first_ts = ts($first_ts);
 print <<ENDHTML;
   ]);
 
+  function majorAxis(date, scale, step) {
+	var s = date / 1000;
+	var precision;
+
+	if (scale == 'millisecond')
+		precision = 6;
+	else if (scale == 'second')
+		precision = 3;
+	else
+		precision = 0;
+
+	return s.toFixed(precision) + "s";
+  }
+
+  function minorAxis(date, scale, step) {
+	var ms = date;
+	var precision;
+	var unit;
+
+	if (scale == 'millisecond') {
+		ms %= 1000;
+		precision = 0;
+		unit = 'ms';
+	} else if (scale == 'second') {
+		ms /= 1000;
+		precision = 1;
+		unit = 's';
+	} else {
+		ms /= 1000;
+		precision = 0;
+		unit = 's';
+	}
+
+	return ms.toFixed(precision) + unit;
+  }
+
   // Configuration for the Timeline
   var options = { groupOrder: 'content',
 		  horizontalScroll: true,
@@ -1007,6 +1043,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 igt-dev mailing list