Mercurial > hg > Game > Cerium
view example/regex_mas/time.pl @ 1786:ba6ffc679a8f draft
minor fix
author | Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp> |
---|---|
date | Sat, 30 Nov 2013 21:06:44 +0900 |
parents | 3cfc65841ef7 |
children |
line wrap: on
line source
#!/usr/bin/perl # update 7th August 2013 # ./regex をcpu数と実行回数を設定して # 実行時間のMAXとminとaverageを # msで出力するスクリプト use strict; use warnings; use Math::Round; #有効数字以下四捨五入 my $loop_counter = 0; my $exec_result = 0; my $time_result = 0; my $total_time = 0; my $min_time = 0; my $max_time = 0; my $ave_time = 0; #average_time my $error_cnt = 0; my $looped_num = 0; if (@ARGV != 2) { print("Usage: ./time.pl [cpu_num] [regex_exec_num]\n"); exit(0); } my $cpu_num = $ARGV[0]; my $loop_num = $ARGV[1]; print "------setting------\n"; print " cpu_num = $cpu_num\n"; print "regex_exec_num = $loop_num\n"; print "------result(ms)---\n"; while ($loop_counter < $loop_num){ $exec_result = `./regex -file c.txt -cpu $cpu_num`; #実行時のコマンドをここで入力 if($exec_result =~ /Time:/){ if($exec_result =~ /(\d+\.\d+)/ ){ $time_result = $1 * 1000; #元の単位がsなので、ここでmsに変換 if($min_time == 0) {$min_time = $time_result}; if($time_result < $min_time) {$min_time = $time_result}; if($time_result > $max_time) {$max_time = $time_result}; $total_time += $time_result; #print "Time:$time_result\n"; ++$loop_counter; } } ++$looped_num; } $ave_time = nearest(.001,$total_time / $loop_num); #小数点第4位未満四捨五入 (Math::Round) print "max:$max_time\n"; print "min:$min_time\n"; print "ave:$ave_time\n"; my $bug_num = $looped_num - $loop_counter; print "bug_num:$bug_num\n";