Skip to content

Instantly share code, notes, and snippets.

@negokaz
Last active August 31, 2015 01:50
Show Gist options
  • Select an option

  • Save negokaz/77cfa952d6d3097af5db to your computer and use it in GitHub Desktop.

Select an option

Save negokaz/77cfa952d6d3097af5db to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
# 1970-01-01 00:00:00からの秒数.ミリ秒返す
function millisec() {
echo $(date +%s).$(expr $(date +%N) / 1000000)
}
# コマンドの実行時間を計測する
# 例)
# measure echo "hello"
function measure() {
echo "COMMAND: $@"
start_time=$(millisec)
$@ > >(awk '{print "\t > ", $0}') 2>&1
end_time=$(millisec)
result=`echo "$end_time - $start_time"|bc`
echo "PROCESS TIME: $result"
echo "---------------------"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment