@kyanny's blog

My thoughts, my life. Views/opinions are my own.

任意のコマンドの実行時間を計測する p5-stopwatch.pl というプログラムを書いた

任意のコマンドの実行時間を計測する p5-stopwatch.pl というプログラムを書いた。 Time::HiRes モジュールが必要です。

kyanny/p5-stopwatch.pl - GitHub

使い方。

  $ ./stopwatch.pl \
      --initialize 'curl -O http://memcached.googlecode.com/files/memcached-1.4.9.tar.gz' \
      --before     'tar xzf memcached-1.4.9.tar.gz' \
      --main       'cd memcached-1.4.9 && ./configure && make' \
      --after      'cd memcached-1.4.9 && make clean' \
      --finalize   'rm -rf memcached-1.4.9 && rm memcached-1.4.9.tar.gz' \
      --count 10

実行結果。

Trying 10 times... 
initializing...
1: run before hook...
1: run main...
1: Elapsed: 11.714476
1: run after hook...
2: run before hook...
2: run main...
2: Elapsed: 11.692463
2: run after hook...
3: run before hook...
3: run main...
3: Elapsed: 11.668393
3: run after hook...
4: run before hook...
4: run main...
4: Elapsed: 11.462474
4: run after hook...
5: run before hook...
5: run main...
5: Elapsed: 11.932532
5: run after hook...
6: run before hook...
6: run main...
6: Elapsed: 11.123197
6: run after hook...
7: run before hook...
7: run main...
7: Elapsed: 11.241909
7: run after hook...
8: run before hook...
8: run main...
8: Elapsed: 11.380771
8: run after hook...
9: run before hook...
9: run main...
9: Elapsed: 11.41942
9: run after hook...
10: run before hook...
10: run main...
10: Elapsed: 11.477144
10: run after hook...
finalizing...
Total: 115.112779

memcached のコンパイルにどれくらい時間がかかるかベンチマークをとりたくなったときなどにご利用ください。