comparison example/bm_search/time.pl @ 1976:a8f4227d6a21 draft

rename regex_mas to bm_search
author Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
date Mon, 03 Mar 2014 19:12:02 +0900
parents example/regex_mas/time.pl@3cfc65841ef7
children
comparison
equal deleted inserted replaced
1975:4cf85b48ab9e 1976:a8f4227d6a21
1 #!/usr/bin/perl
2
3 # update 7th August 2013
4 # ./regex をcpu数と実行回数を設定して
5 # 実行時間のMAXとminとaverageを
6 # msで出力するスクリプト
7
8 use strict;
9 use warnings;
10 use Math::Round; #有効数字以下四捨五入
11
12 my $loop_counter = 0;
13 my $exec_result = 0;
14 my $time_result = 0;
15 my $total_time = 0;
16 my $min_time = 0;
17 my $max_time = 0;
18 my $ave_time = 0; #average_time
19 my $error_cnt = 0;
20 my $looped_num = 0;
21
22 if (@ARGV != 2) {
23 print("Usage: ./time.pl [cpu_num] [regex_exec_num]\n");
24 exit(0);
25 }
26
27 my $cpu_num = $ARGV[0];
28 my $loop_num = $ARGV[1];
29 print "------setting------\n";
30 print " cpu_num = $cpu_num\n";
31 print "regex_exec_num = $loop_num\n";
32 print "------result(ms)---\n";
33
34 while ($loop_counter < $loop_num){
35
36 $exec_result = `./regex -file c.txt -cpu $cpu_num`; #実行時のコマンドをここで入力
37 if($exec_result =~ /Time:/){
38 if($exec_result =~ /(\d+\.\d+)/ ){
39 $time_result = $1 * 1000; #元の単位がsなので、ここでmsに変換
40
41 if($min_time == 0) {$min_time = $time_result};
42 if($time_result < $min_time) {$min_time = $time_result};
43 if($time_result > $max_time) {$max_time = $time_result};
44
45 $total_time += $time_result;
46 #print "Time:$time_result\n";
47 ++$loop_counter;
48 }
49 }
50 ++$looped_num;
51 }
52
53 $ave_time = nearest(.001,$total_time / $loop_num); #小数点第4位未満四捨五入 (Math::Round)
54
55 print "max:$max_time\n";
56 print "min:$min_time\n";
57 print "ave:$ave_time\n";
58
59 my $bug_num = $looped_num - $loop_counter;
60 print "bug_num:$bug_num\n";