0

Currently, the time $0 command within my bash script shows the following similar output

time $0

real    0m0.000s
user    0m0.000s
sys     0m0.000s

but ideally, I would like to see the execution time of the script in nanoseconds. How would this be done? Thanks

RavinderSingh13
  • 130,504
  • 14
  • 57
  • 93
DarkEvE
  • 17
  • 6

2 Answers2

1

I'm afraid that you won't get reliable measurements with this precision.

Worth reading

0

This solution worked

start_time="$(date -u +%N)"
end_time="$(date -u +%N)"
nanotime="$(bc <<<"$end_time-$start_time")"
echo "$nanotime"
DarkEvE
  • 17
  • 6