Reputation: 1281
I was wondering if there is any linux command (like time or /usr/bin/time) that provides the execution time of one command with high precision in nanoseconds
Upvotes: 6
Views: 7217
Reputation: 715
I was unable to find any ready-to-use tool, and wrote myself:
$ cat precision-time
#!/bin/bash
start="$(date +'%s.%N')"
$@
echo "$(date +"%s.%N - ${start}" | bc)" >&2
Usage:
$ ./precision-time sleep 1
1.002805151
Upvotes: 2
Reputation: 171373
strace -c
will count system time in microseconds
strace -ttt
will show time of day (with microseconds) for each line of output.
Getting a total time in nanoseconds is probably not useful, because the jitter due to forking and process startup will be orders of magnitude larger than a nanosecond anyway.
Upvotes: 4