diff 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
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/example/bm_search/time.pl	Mon Mar 03 19:12:02 2014 +0900
@@ -0,0 +1,60 @@
+#!/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";