strace: relative or absolute time? Both!

Strace tool could print out time in relative or absolute format.

But what if you need to show both times? Well, strace couldn’t do it, so, here’s awk’s script to convert absolute time log (collected using -o argument) to format: relative_time absolute_time trace_call

cat > relabstime.awk <<EOFEOF BEGIN{ th=0; tm=0; ts=0.0; start=0.0; } { if (ts==0.0) { printf "%13.6f ", ts; } else { printf "%13.6f ", (3600*(substr(\$1,0,2)-th)+ \\ 60*(substr(\$1,3,2)-tm)+ \\ (substr(\$1,7)-ts)); }; th=substr(\$1, 0, 2); tm=substr(\$1, 3, 2); ts=substr(\$1, 7); if (start==0.0) { start=3600*th+60*tm+ts; } print \$0; } END { printf "Total time: %13.6fs\n", (3600*th+60*tm+ts)-start; } EOFEOF awk -f relabstime.awk /tmp/seq.strace

Note also, this code don’t calculate whole time, only seconds, so, to look for long-time-run tool need to make some modification with it.

HH

Leave a Reply

Your email address will not be published. Required fields are marked *