Just the processing please

One of the many enhancements to well known tools like truss was the introduction of the option -G to said command. When you truss for a command with -E it shows you the delta between entering the syscall and exiting it. However that doesn’t nessesarily means, that the syscall was working all the time, for all purposes it could have slept most of the time. Still when you stay for example in the nanosleep syscall it will show one second of runtime albeit significantly less time was active processing. As the nanosleep name suggests, it sleeps and does only a little bit of work.

Sometimes you want to know, how long the the syscall was actually doing something. With the -G option the time shown by truss is actually showing how much time the syscall did some processing (or to say it differently: was not sleeping).

I think an example makes the difference clear. I’m using an example that was used by a colleague because it’s so great to show the difference between the two options.

root@solaris:~# truss -E -t nanosleep /bin/sleep 1
 1.000278    nanosleep(0x7FDA23DD6A30, 0x7FDA23DD6A40)	= 0
root@solaris:~# truss -G -t nanosleep /bin/sleep 1
 0.000085    nanosleep(0x7FCD2AFF6E10, 0x7FCD2AFF6E20)	= 0