Last active
August 31, 2015 01:50
-
-
Save negokaz/77cfa952d6d3097af5db to your computer and use it in GitHub Desktop.
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
| #!/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