Created
November 23, 2011 10:14
-
-
Save kiyotakagoto/1388337 to your computer and use it in GitHub Desktop.
perlでミリ秒を求める
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
use Time::HiRes; | |
my $num = 0; | |
##### gettimeofday() は、1つ目の要素が整数秒、2つ目の要素が小数点以下の数値である配列を返す | |
my $start_time = join '.', Time::HiRes::gettimeofday; | |
while ( $num < 10000000 ) { | |
print $num++, "\n"; | |
} | |
my $end_time = join '.', Time::HiRes::gettimeofday; | |
my $diff = $end_time - $start_time; | |
print "costs : ${diff}\n"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment