[script] Add simple benchmark script
`benchmark` can be invoked with an executable file after it. It will output the running time in milliseconds. Depends on gnu date being installed on the system.
This commit is contained in:
parent
3e2d17aa5f
commit
a110acbdbf
|
@ -0,0 +1,18 @@
|
|||
#!/usr/bin/env sh
|
||||
# Benchmarking script using gnu date
|
||||
# can be used to output running time of script in milliseconds
|
||||
|
||||
# usage: benchmark scripttorun
|
||||
#
|
||||
# Note: script itself uses roughly 1 millisecond (on my system), so subtract that
|
||||
# from https://unix.stackexchange.com/a/334152
|
||||
|
||||
START=$(date +%s.%N)
|
||||
# do something #######################
|
||||
|
||||
"$@" 1>/dev/null 2>/dev/null
|
||||
|
||||
#######################################
|
||||
END=$(date +%s.%N)
|
||||
DIFF=$(echo "scale=3; (${END} - ${START})*1000/1" | bc)
|
||||
echo "${DIFF}"
|
Loading…
Reference in New Issue