Skip to content

Commit

Permalink
scripts: Correct dump scripts timestamp representation
Browse files Browse the repository at this point in the history
As the timestamp represents in nanosecond unit, dump script wants to
show in second unit. But, in modular, the digits may not filled enough

ex.
  _time = 1001002003
  _time / unit == 1
  _time % unit == 1002003

expected:
  1.001002003

actual:
  1.1002003
  // may translated as 1s, 100ms, 200us, 300ns

So, need to change formatting text to start with leading zero, fixed
nine digits.

Signed-off-by: JaeSang Yoo <[email protected]>
  • Loading branch information
JSYoo5B authored and namhyung committed Sep 6, 2022
1 parent bac387d commit 4c56010
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions scripts/dump.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function uftrace_entry(ctx)
local _name = ctx['name']

local unit = 1000000000
print(string.format('%d.%d %6d: [entry] %s(%x) depth: %d',
print(string.format('%d.%09d %6d: [entry] %s(%x) depth: %d',
_time / unit, _time % unit, _tid, _name, _address, _depth))

if ctx['args'] ~= nil then
Expand All @@ -39,7 +39,7 @@ function uftrace_exit(ctx)
local _name = ctx["name"]

local unit = 1000000000
print(string.format('%d.%d %6d: [exit ] %s(%x) depth: %d',
print(string.format('%d.%09d %6d: [exit ] %s(%x) depth: %d',
_time / unit, _time % unit, _tid, _name, _address, _depth))

if ctx['retval'] ~= nil then
Expand All @@ -55,7 +55,7 @@ function uftrace_event(ctx)
local _name = ctx["name"]

local unit = 1000000000
print(string.format('%d.%d %6d: [event] %s(%x)',
print(string.format('%d.%09d %6d: [event] %s(%x)',
_time / unit, _time % unit, _tid, _name, _address))
end

Expand Down
6 changes: 3 additions & 3 deletions scripts/dump.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def uftrace_entry(ctx):
_name = ctx["name"]

unit = 10 ** 9
print("%d.%d %6d: [entry] %s(%x) depth: %d" %
print("%d.%09d %6d: [entry] %s(%x) depth: %d" %
(_time / unit, _time % unit, _tid, _name, _address, _depth))

if "args" in ctx:
Expand All @@ -47,7 +47,7 @@ def uftrace_exit(ctx):
_name = ctx["name"]

unit = 10 ** 9
print("%d.%d %6d: [exit ] %s(%x) depth: %d" %
print("%d.%09d %6d: [exit ] %s(%x) depth: %d" %
(_time / unit, _time % unit, _tid, _name, _address, _depth))

if "retval" in ctx:
Expand All @@ -62,7 +62,7 @@ def uftrace_event(ctx):
_name = ctx["name"]

unit = 10 ** 9
print("%d.%d %6d: [event] %s(%x)" %
print("%d.%09d %6d: [event] %s(%x)" %
(_time / unit, _time % unit, _tid, _name, _address))

# uftrace_end is optional, so can be omitted.
Expand Down

0 comments on commit 4c56010

Please sign in to comment.