[igt-dev] [PATCH i-g-t 05/11] trace.pl: Fix HTML timestamp generation
Tvrtko Ursulin
tursulin at ursulin.net
Mon Jul 9 13:19:58 UTC 2018
From: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
Now that we scale timestamps to get better timeline granularity, the hacky
hand rolled micro-second time to HTML date conversion does no longer cut
it.
Use perl built-in gmtime to handle things properly.
Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
Cc: John Harrison <John.C.Harrison at Intel.com>
---
scripts/trace.pl | 15 ++++-----------
1 file changed, 4 insertions(+), 11 deletions(-)
diff --git a/scripts/trace.pl b/scripts/trace.pl
index e2978e5382c2..aeaf2392162e 100755
--- a/scripts/trace.pl
+++ b/scripts/trace.pl
@@ -346,24 +346,17 @@ sub sanitize_ctx
sub ts
{
my ($us) = @_;
- my ($d, $h, $m, $s);
+ my ($y, $mo, $d, $h, $m, $s);
$us *= 1000 unless $no_timeline_scaling;
$s = int($us / 1000000);
$us = $us % 1000000;
- $m = int($s / 60);
- $s = $s % 60;
+ ($s, $m, $h, $d, $mo, $y) = gmtime($s);
- $h = int($m / 60);
- $m = $m % 60;
-
- $d = 1 + int($h / 24);
- $h = $h % 24;
-
- return sprintf('2017-01-%02u %02u:%02u:%02u.%06u',
- int($d), int($h), int($m), int($s), int($us));
+ return sprintf('%04u-%02u-%02u %02u:%02u:%02u.%06u',
+ 1970 + $y, 1 + $mo, $d, $h, $m, $s, int($us));
}
# Main input loop - parse lines and build the internal representation of the
--
2.17.1
More information about the igt-dev
mailing list