-
Notifications
You must be signed in to change notification settings - Fork 0
/
opensm-cc-tester-test0.rb
44 lines (37 loc) · 1.23 KB
/
opensm-cc-tester-test0.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/ruby
# Configuration testing script for IB CC Study
# Perry Huang
if(ARGV[0].to_s == "")
fail("Usage: ./opensm-cc-tester.rb [dir]")
end
$dir = ARGV[0]
$result_name = "results.csv"
result_file = File.open($result_name, "w")
averages = Array.new
result_file.puts "conf_file,receive_A,receive_B"
result_file.close
Dir.foreach($dir) do |conf|
if(conf == '.' || conf == '..') then
next
end
result_file = File.open($result_name, "a")
opensm_process_id = fork do
exec '/home/huang32/opensm', "--conf", "#{$dir}/#{conf}"
end
puts "Loaded new process for opensm with #{conf} and process id #{opensm_process_id}"
puts "Waiting for 5 seconds for opensm to finish loading"
sleep 5
retval = `sh congest.sh | grep "[R]" | awk '{if (cnt % 2 == 0) sum1+=$9;if (cnt % 2 == 1) sum2+=$9;cnt++} END {print sum1/((cnt-1)/2); print sum2/((cnt-1)/2)}'`
puts "Running congest.sh"
retval = retval.sub("\n", " ")
retval = retval.sub("\n", "")
retval = retval.split(" ")
receive_A = retval[1]
receive_B = retval[0]
result_file.puts "#{conf},#{receive_A},#{receive_B}"
puts "Results for #{conf} saved to #{$result_name}"
Process.kill("SIGKILL", opensm_process_id)
puts "Process #{opensm_process_id} killed"
result_file.close
end