Mercurial > hg > Game > Cerium
comparison example/regex_mas/time.pl @ 1681:7bc7780e8ece draft
add time.pl
author | Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp> |
---|---|
date | Wed, 07 Aug 2013 02:27:44 +0900 |
parents | |
children | 0b38dd5439d5 |
comparison
equal
deleted
inserted
replaced
1680:e44e5a18392c | 1681:7bc7780e8ece |
---|---|
1 #!/usr/bin/perl | |
2 use strict; | |
3 use warnings; | |
4 | |
5 my $loop_count = 0; | |
6 my $exec_result = 0; | |
7 my $time_result = 0; | |
8 my $total_time = 0; | |
9 my $min_time = 0; | |
10 my $max_time = 0; | |
11 my $ave_time = 0; #average_time | |
12 | |
13 print "------setting------\n"; | |
14 print " cpu_num = $ARGV[0]\n"; | |
15 print "regex_exec_num = $ARGV[1]\n"; | |
16 print "------result(ms)---\n"; | |
17 | |
18 while ($loop_count < $ARGV[1]){ | |
19 | |
20 $exec_result = `./regex -file c.txt -cpu $ARGV[0]`; | |
21 | |
22 if($exec_result =~ /(\d+\.\d+)/ ){ | |
23 $time_result = $1 * 1000; #元の単位がsなので、ここでmsに変換 | |
24 | |
25 if($min_time == 0) {$min_time = $time_result}; | |
26 if($time_result < $min_time) {$min_time = $time_result}; | |
27 if($time_result > $max_time) {$max_time = $time_result}; | |
28 | |
29 $total_time += $time_result; | |
30 } | |
31 | |
32 #print "time:$time_result\n"; | |
33 ++$loop_count; | |
34 } | |
35 | |
36 $ave_time = $total_time / $ARGV[1]; | |
37 | |
38 print "max:$max_time\n"; | |
39 print "min:$min_time\n"; | |
40 print "ave:$ave_time\n"; #有効数字3桁なので、平均も有効数字3桁にする??? |