changeset 1683:0b38dd5439d5 draft

insert error message regex_mas/time.pl .
author Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
date Wed, 07 Aug 2013 14:15:47 +0900
parents 7d01a2891710
children eb3daec80cbb
files example/regex_mas/time.pl
diffstat 1 files changed, 20 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/example/regex_mas/time.pl	Wed Aug 07 02:34:33 2013 +0900
+++ b/example/regex_mas/time.pl	Wed Aug 07 14:15:47 2013 +0900
@@ -1,8 +1,14 @@
 #!/usr/bin/perl
+
+# update 7th August 2013
+# ./regex をcpu数と実行回数を設定して
+# 実行時間のMAXとminとaverageを
+# msで出力するスクリプト
+
 use strict;
 use warnings;
 
-my $loop_count = 0;
+my $loop_counter = 0;
 my $exec_result = 0;
 my $time_result = 0;
 my $total_time = 0;
@@ -10,14 +16,21 @@
 my $max_time = 0;
 my $ave_time = 0; #average_time
 
+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    = $ARGV[0]\n";
-print "regex_exec_num = $ARGV[1]\n";
+print "    cpu_num    = $cpu_num\n";
+print "regex_exec_num = $loop_num\n";
 print "------result(ms)---\n";
 
-while ($loop_count < $ARGV[1]){
+while ($loop_counter < $loop_num){
 
-    $exec_result = `./regex -file c.txt -cpu $ARGV[0]`;
+    $exec_result = `./regex -file c.txt -cpu $cpu_num`; #実行時のコマンドをここで入力
 
     if($exec_result =~ /(\d+\.\d+)/ ){
         $time_result = $1 * 1000; #元の単位がsなので、ここでmsに変換
@@ -30,10 +43,10 @@
     }
 
     #print "time:$time_result\n";
-    ++$loop_count;
+    ++$loop_counter;
 }
 
-$ave_time = $total_time / $ARGV[1];
+$ave_time = $total_time / $loop_num;
 
 print "max:$max_time\n";
 print "min:$min_time\n";