Re: [PATCH i-g-t 1/8] trace.pl: Improve time axis labels

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 7/18/2018 2:45 AM, Tvrtko Ursulin wrote:
From: Tvrtko Ursulin <tvrtko.ursulin@xxxxxxxxx>

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.

v3:
  * Drop all date complications and just use micro seconds throughout.
    (John Harrison)

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@xxxxxxxxx>
Suggested-by: Chris Wilson <chris@xxxxxxxxxxxxxxxxxx>
Cc: Chris Wilson <chris@xxxxxxxxxxxxxxxxxx>
Cc: John Harrison <John.C.Harrison@xxxxxxxxx>
Reviewed-by: John Harrison <John.C.Harrison@xxxxxxxxx> # v2
---
  scripts/trace.pl | 72 ++++++++++++++++++++++++++++++++----------------
  1 file changed, 48 insertions(+), 24 deletions(-)

diff --git a/scripts/trace.pl b/scripts/trace.pl
index fc1713e4f9a7..3ad5effafd0a 100755
--- a/scripts/trace.pl
+++ b/scripts/trace.pl
@@ -329,20 +329,6 @@ sub sanitize_ctx
  	}
  }
-sub ts
-{
-	my ($us) = @_;
-	my ($y, $mo, $d, $h, $m, $s);
-
-	$s = int($us / 1000000);
-	$us = $us % 1000000;
-
-	($s, $m, $h, $d, $mo, $y) = gmtime($s);
-
-	return sprintf('%04u-%02u-%02u %02u:%02u:%02u.%06u',
-		        $y, 1 + $mo, $d, $h, $m, $s, int($us));
-}
-
  # Main input loop - parse lines and build the internal representation of the
  # trace using a hash of requests and some auxilliary data structures.
  my $prev_freq = 0;
@@ -912,7 +898,7 @@ foreach my $key (sort sortQueue keys %db) {
  		$style = 'color: black; background-color: ' .
  			 ctx_colour($ctx, 'queue');
  		$content = "$name<br>$db{$key}->{'submit-delay'}us <small>($db{$key}->{'execute-delay'}us)</small>";
-		$startend = 'start: \'' . ts($queue) . '\', end: \'' . ts($submit) . '\'';
+		$startend = 'start: ' . $queue . ', end: ' . $submit;
  		print "\t{id: $i, key: $skey, $type group: $group, subgroup: $subgroup, subgroupOrder: $subgroup, content: '$content', $startend, style: \'$style\'},\n";
  		$i++;
  	}
@@ -923,7 +909,7 @@ foreach my $key (sort sortQueue keys %db) {
  		$style = 'color: black; background-color: ' .
  			 ctx_colour($ctx, 'ready');
  		$content = "<small>$name<br>$db{$key}->{'execute-delay'}us</small>";
-		$startend = 'start: \'' . ts($submit) . '\', end: \'' . ts($start) . '\'';
+		$startend = 'start: ' . $submit . ', end: ' . $start;
  		print "\t{id: $i, key: $skey, $type group: $group, subgroup: $subgroup, subgroupOrder: $subgroup, content: '$content', $startend, style: \'$style\'},\n";
  		$i++;
  	}
@@ -942,7 +928,7 @@ foreach my $key (sort sortQueue keys %db) {
  		$content .= ' <small><i>++</i></small> ' if exists $db{$key}->{'no-end'};
  		$content .= ' <small><i>+</i></small> ' if exists $db{$key}->{'no-notify'};
  		$content .= "<br>$db{$key}->{'duration'}us <small>($db{$key}->{'context-complete-delay'}us)</small>";
-		$startend = 'start: \'' . ts($start) . '\', end: \'' . ts($notify) . '\'';
+		$startend = 'start: ' . $start . ', end: ' . $notify;
  		print "\t{id: $i, key: $skey, $type group: $group, subgroup: $subgroup, subgroupOrder: $subgroup, content: '$content', $startend, style: \'$style\'},\n";
  		$i++;
  	}
@@ -956,7 +942,7 @@ foreach my $key (sort sortQueue keys %db) {
  		$content .= ' <small><i>???</i></small> ' if exists $db{$key}->{'incomplete'};
  		$content .= ' <small><i>++</i></small> ' if exists $db{$key}->{'no-end'};
  		$content .= ' <small><i>+</i></small> ' if exists $db{$key}->{'no-notify'};
-		$startend = 'start: \'' . ts($notify) . '\', end: \'' . ts($end) . '\'';
+		$startend = 'start: ' . $notify . ', end: ' . $end;
  		print "\t{id: $i, key: $skey, $type group: $group, subgroup: $subgroup, subgroupOrder: $subgroup, content: '$content', $startend, style: \'$style\'},\n";
  		$i++;
  	}
@@ -974,7 +960,7 @@ foreach my $item (@freqs) {
$start = $first_ts if $start < $first_ts;
  	$end = $last_ts if $end > $last_ts;
-	$startend = 'start: \'' . ts($start) . '\', end: \'' . ts($end) . '\'';
+	$startend = 'start: ' . $start . ', end: ' . $end;
  	print "\t{id: $i, type: 'range', group: 0, content: '$freq', $startend},\n";
  	$i++;
  }
@@ -988,18 +974,55 @@ if ($gpu_timeline) {
$start = $first_ts if $start < $first_ts;
  		$end = $last_ts if $end > $last_ts;
-		$startend = 'start: \'' . ts($start) . '\', end: \'' . ts($end) . '\'';
+		$startend = 'start: ' . $start . ', end: ' . $end;
  		print "\t{id: $i, type: 'range', group: 1, $startend},\n";
  		$i++;
  	}
  }
-my $end_ts = ts($first_ts + $width_us);
-$first_ts = ts($first_ts);
+my $end_ts = $first_ts + $width_us;
+$first_ts = $first_ts;
print <<ENDHTML;
    ]);
+ function majorAxis(date, scale, step) {
+	var s = date / 1000000;
+	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 t = date;
+	var precision;
+	var unit;
+
+	if (scale == 'millisecond') {
+		t %= 1000;
+		precision = 0;
+		unit = 'us';
+	} else if (scale == 'second') {
+		t /= 1000;
+		t %= 1000;
+		precision = 0;
+		unit = 'ms';
+	} else {
+		t /= 1000000;
+		precision = 1;
+		unit = 's';
+	}
+
+	return t.toFixed(precision) + unit;
+  }
+
    // Configuration for the Timeline
    var options = { groupOrder: 'content',
  		  horizontalScroll: true,
@@ -1007,8 +1030,9 @@ print <<ENDHTML;
  		  stackSubgroups: false,
  		  zoomKey: 'ctrlKey',
  		  orientation: 'top',
-		  start: '$first_ts',
-		  end: '$end_ts'};
+		  format: { majorLabels: majorAxis, minorLabels: minorAxis },
+		  start: $first_ts,
+		  end: $end_ts};
// Create a Timeline
    var timeline = new vis.Timeline(container, items, groups, options);

Woohoo!

This one seems to work fine on both Firefox and Chrome. It even works on IE and Edge unlike the previous version! I guess they can only cope with raw times not dates!?

One thing I've just noticed is that there is also a 'now' line on the timeline - a red vertical bar across the entire timeline. On the old 'date' versions, it was following the current system time and hence wandering forwards at one second per second. On this version, it is out of position and advancing at one millisecond per second. Presumably because you are scaling the axes by a factor of one thousand in order to gain the necessary precision in the plot. Something of a curiosity but certainly not a problem!

Ship it :)

Reviewed-by: John Harrison <John.C.Harrison@xxxxxxxxx>


_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/intel-gfx




[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux