summaryrefslogtreecommitdiffstats
path: root/eshprof
diff options
context:
space:
mode:
authorP. J. McDermott <pj@pehjota.net>2016-02-27 13:40:06 (EST)
committer P. J. McDermott <pj@pehjota.net>2016-02-27 13:40:06 (EST)
commita7ff3833eb46366370377e93337847c5d3d06af1 (patch)
treef30f95c171d5d7aa14425341312985535bbe28bd /eshprof
parentdc565174364828aa76d9bc8fd7e0d11bd634c708 (diff)
downloadeggshell-a7ff3833eb46366370377e93337847c5d3d06af1.zip
eggshell-a7ff3833eb46366370377e93337847c5d3d06af1.tar.gz
eggshell-a7ff3833eb46366370377e93337847c5d3d06af1.tar.bz2
eshprof: Show time per call
Diffstat (limited to 'eshprof')
-rw-r--r--eshprof/flat-profile.esh10
1 files changed, 7 insertions, 3 deletions
diff --git a/eshprof/flat-profile.esh b/eshprof/flat-profile.esh
index c928b37..571f1d2 100644
--- a/eshprof/flat-profile.esh
+++ b/eshprof/flat-profile.esh
@@ -164,18 +164,22 @@ show_table()
local time=
local percent=
local calls=
+ local time_per_call=
- printf ' self\n'
- printf '%% time seconds calls name\n'
+ printf ' self self\n'
+ printf '%% time seconds calls ms/call name\n'
for fn in ${fns}; do
eval "time=\${fn_timing_${fn}}"
+ eval "calls=\${fn_calls_${fn}}"
percent=$(printf 'scale = 2; 100 * %d / %d\n' \
${time} ${total_runtime} | bc)
time=$(printf 'scale = 9; %d / 1000000000\n' ${time} | bc)
- eval "calls=\${fn_calls_${fn}}"
+ time_per_call=$(printf 'scale = 6; %s * 1000 / %s\n' \
+ ${time} ${calls} | bc)
printf '%6.2f ' ${percent}
printf '%14.9f ' ${time}
printf '%8d ' ${calls}
+ printf '%11.6f ' ${time_per_call}
printf '%s\n' "${fn}"
done | sort -nr -k 1,4
}