Skip to content
Browse files

allow setting both # of runs and # of rounds

  • Loading branch information...
1 parent d9e5add commit 9c508a5ef7cd84c32d90001524e6a027240e4f94 @ryw ryw committed
Showing with 16 additions and 9 deletions.
  1. +16 −9 multi_run.rb
View
25 multi_run.rb
@@ -1,16 +1,23 @@
#!/usr/bin/env ruby
+require 'optparse'
-last_line = []
+options = {}
+OptionParser.new do |opts|
+ opts.on("-r", "--runs N", Integer, "Number of runs") do |runs|
+ options[:runs] = runs
+ end
+ opts.on("-o", "--rounds N", Integer, "Number of rounds") do |rounds|
+ options[:rounds] = rounds
+ end
+end.parse!
-if ARGV.size > 1 and ARGV[0] == "-r" and ARGV[1] =~ /^[1-9]\d*$/
- ARGV.shift
- runs = ARGV.shift.to_i
-else
- runs = 1000
-end
+options[:runs] = 1000 unless options[:runs]
+options[:rounds] = 10 unless options[:rounds]
+
+last_line = []
-runs.times do
- output = `ruby ./engine.rb`
+options[:runs].times do
+ output = `ruby ./engine.rb -r #{options[:rounds]}`
last_line.push output.split("\n").last
end

0 comments on commit 9c508a5

Please sign in to comment.
Something went wrong with that request. Please try again.