From: Tvrtko Ursulin <[email protected]>

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 <[email protected]>
Cc: John Harrison <[email protected]>
---
 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

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

Reply via email to