From 50add555aee89e25ee540f96e1212f1e140bdea7 Mon Sep 17 00:00:00 2001 From: Tvrtko Ursulin Date: Thu, 12 Jul 2018 10:22:50 +0100 Subject: trace.pl: Improve time axis labels 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 Suggested-by: Chris Wilson Cc: Chris Wilson Cc: John Harrison Reviewed-by: John Harrison --- scripts/trace.pl | 72 +++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 48 insertions(+), 24 deletions(-) (limited to 'scripts') diff --git a/scripts/trace.pl b/scripts/trace.pl index fc1713e4..3ad5effa 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
$db{$key}->{'submit-delay'}us ($db{$key}->{'execute-delay'}us)"; - $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 = "$name
$db{$key}->{'execute-delay'}us
"; - $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 .= ' ++ ' if exists $db{$key}->{'no-end'}; $content .= ' + ' if exists $db{$key}->{'no-notify'}; $content .= "
$db{$key}->{'duration'}us ($db{$key}->{'context-complete-delay'}us)"; - $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 .= ' ??? ' if exists $db{$key}->{'incomplete'}; $content .= ' ++ ' if exists $db{$key}->{'no-end'}; $content .= ' + ' 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 <