Created
July 4, 2022 04:01
-
-
Save arc279/c567ce958367e7598a4abf2b08be8707 to your computer and use it in GitHub Desktop.
bash + awk で経過時間をミリ秒で取得
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function elapsed_millisec() { | |
BEFORE=$(date +%s%3N) | |
eval "${@}" | |
AFTER=$(date +%s%3N) | |
awk -v OFMT="%.3f" -v before=${BEFORE} -v after=${AFTER} 'BEGIN { print (after - before) / 1000 }' | |
} | |
elapsed_millisec sleep 1.234 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment