annotate 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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1681
7bc7780e8ece add time.pl
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 #!/usr/bin/perl
1683
0b38dd5439d5 insert error message regex_mas/time.pl .
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 1681
diff changeset
2
0b38dd5439d5 insert error message regex_mas/time.pl .
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 1681
diff changeset
3 # update 7th August 2013
0b38dd5439d5 insert error message regex_mas/time.pl .
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 1681
diff changeset
4 # ./regex をcpu数と実行回数を設定して
0b38dd5439d5 insert error message regex_mas/time.pl .
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 1681
diff changeset
5 # 実行時間のMAXとminとaverageを
0b38dd5439d5 insert error message regex_mas/time.pl .
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 1681
diff changeset
6 # msで出力するスクリプト
0b38dd5439d5 insert error message regex_mas/time.pl .
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 1681
diff changeset
7
1681
7bc7780e8ece add time.pl
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
diff changeset
8 use strict;
7bc7780e8ece add time.pl
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
diff changeset
9 use warnings;
1685
3b8c12927f45 insert Math::Round in regex_mas/time.pl
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 1683
diff changeset
10 use Math::Round; #有効数字以下四捨五入
1681
7bc7780e8ece add time.pl
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
diff changeset
11
1683
0b38dd5439d5 insert error message regex_mas/time.pl .
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 1681
diff changeset
12 my $loop_counter = 0;
1681
7bc7780e8ece add time.pl
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
diff changeset
13 my $exec_result = 0;
7bc7780e8ece add time.pl
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
diff changeset
14 my $time_result = 0;
7bc7780e8ece add time.pl
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
diff changeset
15 my $total_time = 0;
7bc7780e8ece add time.pl
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
diff changeset
16 my $min_time = 0;
7bc7780e8ece add time.pl
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
diff changeset
17 my $max_time = 0;
7bc7780e8ece add time.pl
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
diff changeset
18 my $ave_time = 0; #average_time
1692
13ffed43fe68 bug fix time.pl
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 1685
diff changeset
19 my $error_cnt = 0;
13ffed43fe68 bug fix time.pl
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 1685
diff changeset
20 my $looped_num = 0;
1681
7bc7780e8ece add time.pl
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
diff changeset
21
1683
0b38dd5439d5 insert error message regex_mas/time.pl .
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 1681
diff changeset
22 if (@ARGV != 2) {
0b38dd5439d5 insert error message regex_mas/time.pl .
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 1681
diff changeset
23 print("Usage: ./time.pl [cpu_num] [regex_exec_num]\n");
0b38dd5439d5 insert error message regex_mas/time.pl .
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 1681
diff changeset
24 exit(0);
0b38dd5439d5 insert error message regex_mas/time.pl .
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 1681
diff changeset
25 }
0b38dd5439d5 insert error message regex_mas/time.pl .
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 1681
diff changeset
26
0b38dd5439d5 insert error message regex_mas/time.pl .
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 1681
diff changeset
27 my $cpu_num = $ARGV[0];
0b38dd5439d5 insert error message regex_mas/time.pl .
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 1681
diff changeset
28 my $loop_num = $ARGV[1];
1681
7bc7780e8ece add time.pl
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
diff changeset
29 print "------setting------\n";
1683
0b38dd5439d5 insert error message regex_mas/time.pl .
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 1681
diff changeset
30 print " cpu_num = $cpu_num\n";
0b38dd5439d5 insert error message regex_mas/time.pl .
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 1681
diff changeset
31 print "regex_exec_num = $loop_num\n";
1681
7bc7780e8ece add time.pl
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
diff changeset
32 print "------result(ms)---\n";
7bc7780e8ece add time.pl
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
diff changeset
33
1683
0b38dd5439d5 insert error message regex_mas/time.pl .
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 1681
diff changeset
34 while ($loop_counter < $loop_num){
1681
7bc7780e8ece add time.pl
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
diff changeset
35
1683
0b38dd5439d5 insert error message regex_mas/time.pl .
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 1681
diff changeset
36 $exec_result = `./regex -file c.txt -cpu $cpu_num`; #実行時のコマンドをここで入力
1693
3cfc65841ef7 fix time.pl
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 1692
diff changeset
37 if($exec_result =~ /Time:/){
1692
13ffed43fe68 bug fix time.pl
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 1685
diff changeset
38 if($exec_result =~ /(\d+\.\d+)/ ){
13ffed43fe68 bug fix time.pl
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 1685
diff changeset
39 $time_result = $1 * 1000; #元の単位がsなので、ここでmsに変換
1681
7bc7780e8ece add time.pl
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
diff changeset
40
1692
13ffed43fe68 bug fix time.pl
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 1685
diff changeset
41 if($min_time == 0) {$min_time = $time_result};
13ffed43fe68 bug fix time.pl
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 1685
diff changeset
42 if($time_result < $min_time) {$min_time = $time_result};
13ffed43fe68 bug fix time.pl
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 1685
diff changeset
43 if($time_result > $max_time) {$max_time = $time_result};
1681
7bc7780e8ece add time.pl
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
diff changeset
44
1692
13ffed43fe68 bug fix time.pl
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 1685
diff changeset
45 $total_time += $time_result;
1693
3cfc65841ef7 fix time.pl
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 1692
diff changeset
46 #print "Time:$time_result\n";
1692
13ffed43fe68 bug fix time.pl
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 1685
diff changeset
47 ++$loop_counter;
13ffed43fe68 bug fix time.pl
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 1685
diff changeset
48 }
1681
7bc7780e8ece add time.pl
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
diff changeset
49 }
1693
3cfc65841ef7 fix time.pl
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 1692
diff changeset
50 ++$looped_num;
1681
7bc7780e8ece add time.pl
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
diff changeset
51 }
7bc7780e8ece add time.pl
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
diff changeset
52
1685
3b8c12927f45 insert Math::Round in regex_mas/time.pl
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 1683
diff changeset
53 $ave_time = nearest(.001,$total_time / $loop_num); #小数点第4位未満四捨五入 (Math::Round)
1681
7bc7780e8ece add time.pl
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
diff changeset
54
7bc7780e8ece add time.pl
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
diff changeset
55 print "max:$max_time\n";
7bc7780e8ece add time.pl
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
diff changeset
56 print "min:$min_time\n";
1685
3b8c12927f45 insert Math::Round in regex_mas/time.pl
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 1683
diff changeset
57 print "ave:$ave_time\n";
1693
3cfc65841ef7 fix time.pl
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 1692
diff changeset
58
3cfc65841ef7 fix time.pl
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 1692
diff changeset
59 my $bug_num = $looped_num - $loop_counter;
3cfc65841ef7 fix time.pl
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 1692
diff changeset
60 print "bug_num:$bug_num\n";