Timer: Difference between revisions

Jump to navigation Jump to search
272 bytes added ,  8 December 2016
mNo edit summary
Line 13: Line 13:
</pre>
</pre>


== Linux command ==
== Linux command (BASH) ==
{{Linux}} console, {{Mac}} Terminal or Cygwin commands on {{Win}}<ref>[http://stackoverflow.com/questions/385408/get-program-execution-time-in-the-shell linux - Get program execution time in the shell - Stack Overflow]</ref>
{{Linux}} console, {{Mac}} Terminal or Cygwin commands on {{Win}}<ref>[http://stackoverflow.com/questions/385408/get-program-execution-time-in-the-shell linux - Get program execution time in the shell - Stack Overflow]</ref><ref>[http://stackoverflow.com/questions/12199631/convert-seconds-to-hours-minutes-seconds bash - Convert seconds to hours, minutes, seconds - Stack Overflow]</ref>
<pre>
<pre>
START=$(date +%s)
START=$(date +%s)
Line 23: Line 23:
END=$(date +%s)
END=$(date +%s)
DIFF=$(( $END - $START ))
DIFF=$(( $END - $START ))
echo "Elapsed time $DIFF seconds"
printf 'Elapsed time %02dh:%02dm:%02ds\n' $(($DIFF/3600)) $(($DIFF%3600/60)) $(($DIFF%60))


# expected result: Elapsed time 00h:00m:02s
</pre>
</pre>


Navigation menu