Last active
May 20, 2016 01:42
-
-
Save silverhammermba/49d4357c12bcceec7394afce21838541 to your computer and use it in GitHub Desktop.
method for testing a program with various settings
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require_relative './test_run' | |
x = run(key_max: 25_000, threads: (1..4), iters: 1_000_000, n: 21, read: 10, branch: %w{locking2}) | |
File.open('box.data', 'w') do |f| | |
x.each do |r| | |
r[:ticks].each { |y| f.puts "#{y} #{r[:threads]}" } | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def product *args | |
trivial_enum = Enumerator.new { |yielder| yielder << [] } | |
args.inject(trivial_enum) do |enum, array| | |
Enumerator.new do |yielder| | |
enum.each do |partial_product| | |
array.each do |obj| | |
yielder << (partial_product + [obj]) | |
end | |
end | |
end | |
end | |
end | |
# run speed tests, return number of ticks | |
# note that iters is (approx.) *total* # of iterations | |
def run(key_max:, threads:, iters:, read: 1, write: 1, erase: 1, pop: 0, n: 1, branch: nil) | |
branch = [branch] unless branch.is_a? Enumerable | |
key_max = [key_max] unless key_max.is_a? Enumerable | |
threads = [threads] unless threads.is_a? Enumerable | |
iters = [iters] unless iters.is_a? Enumerable | |
read = [read] unless read.is_a? Enumerable | |
write = [write] unless write.is_a? Enumerable | |
erase = [erase] unless erase.is_a? Enumerable | |
pop = [pop] unless pop.is_a? Enumerable | |
Enumerator.new do |yielder| | |
Dir.chdir('E:\\CSE475Final') do | |
branch.each do |b| | |
system "git checkout #{b}" if b | |
raise "checkout #{b} failed" unless $?.success? | |
system "msbuild /p:configuration=Release /p:Platform=x64" | |
raise "build #{b} failed" unless $?.success? | |
product(key_max, threads, iters, read, write, erase, pop).each do |k, t, i, r, w, e, o| | |
y = {} | |
y[:branch] = b unless branch.count == 1 | |
y[:key_max] = k unless key_max.count == 1 | |
y[:threads] = t unless threads.count == 1 | |
y[:iters] = i unless iters.count == 1 | |
y[:read] = r unless read.count == 1 | |
y[:write] = w unless write.count == 1 | |
y[:erase] = e unless erase.count == 1 | |
y[:pop] = o unless pop.count == 1 | |
y[:ticks] = n.times.map { Integer(`.\\x64\\Release\\CSE475Final -k #{k} -t #{t} -i #{i/t} -r #{r} -w #{w} -e #{e} -p #{o}`, 10) } | |
y = y[:ticks][0] if y[:ticks].size == 1 | |
yielder << y | |
end | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment