[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
1 changed files with 18 additions and 0 deletions
18
scripts/.local/bin/benchmark
Executable file
18
scripts/.local/bin/benchmark
Executable file
|
@ -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 a new issue