Added --arguments argument to benchmark runner
authorJan Vrany <jan.vrany@fit.cvut.cz>
Wed, 31 Jul 2013 00:48:57 +0100
changeset 143 e702a244cea5
parent 142 c69d1eb92d91
child 144 9617ce45d4ea
Added --arguments argument to benchmark runner This read additional command line arguments from given file. This way, one may save benchmark configuratios to a file (including parameter definitions and suite specs) and then later run them as benchmark-runner --arguments mybenchmark.txt
s/BenchmarkRunner.st
--- a/s/BenchmarkRunner.st	Wed Jul 31 00:03:10 2013 +0100
+++ b/s/BenchmarkRunner.st	Wed Jul 31 00:48:57 2013 +0100
@@ -79,13 +79,14 @@
 
 !BenchmarkRunner methodsFor:'main'!
 
-main:argv
-    | i report machineid file params classes runs |
+main:argv0
+    | i report machineid file params classes runs argv |
 
     params := Dictionary new.
     classes := OrderedCollection new.
     report := BenchmarkReport text.
     runs := 5.
+    argv := argv0 asOrderedCollection.
 
     i := 1.
     [ i <= argv size ] whileTrue:[
@@ -111,6 +112,25 @@
                 file := argv at: i.
                 i := i + 1.
             ].
+            arg = '--arguments' ifTrue:[
+                | arguments argumentsF |
+
+                i > argv size ifTrue:[
+                    self error:'--arguments requires a file parameter.'
+                ].                
+                argumentsF := (arguments := (argv at: i)) asFilename.
+                argumentsF exists ifFalse:[
+                    self error:'no such file: ', arguments.
+                ].
+                argumentsF readingFileDo:[:s|
+                    [ s atEnd ] whileFalse:[
+                        argv add: s nextLine.
+                    ]
+                ].
+                i := i + 1.
+            ].  
+                         
+
             arg = '-r' ifTrue:[
                 | reportNm |
 
@@ -204,7 +224,7 @@
 
     self exit: 0.
 
-    "Modified: / 26-07-2013 / 00:13:11 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 31-07-2013 / 00:44:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 options
@@ -216,6 +236,7 @@
   -o FILE ................ write output to FILE instead of to standard output (default: stdout)
   -n RUNS ................ how many times to run each bechmark (default: 5)
   -r REPORTCLASS ......... user REPORTCLASS to generate report (default: BenchmarkReportText)
+  --arguments FILE ....... read additional arguments from FOLE, one argument per line.
   --text ................. generate text report (equivalent to -r BenchmarkReportText)
   --json ................. generate JSON report (equivalent to -r BenchmarkReportJSON)
   --machineid ID ......... set the machine idetification string for JSON report
@@ -230,7 +251,7 @@
 '
 
     "Created: / 06-06-2013 / 11:01:42 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified: / 13-07-2013 / 16:36:38 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 31-07-2013 / 00:46:15 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !BenchmarkRunner class methodsFor:'documentation'!