-
Notifications
You must be signed in to change notification settings - Fork 1
/
Rakefile
47 lines (39 loc) · 968 Bytes
/
Rakefile
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
45
46
47
require 'tempfile'
task :default => [:build, :start_docker, :clean, :run, :stop_docker, :plot]
task :clean do
sh "rm -f out/*.gnuplot"
end
task :run do
sh "ruby benchmark.rb"
end
task :plot do
sh "rm -rf plots"
sh "mkdir -p plots"
p Dir["out/**/*.gnuplot"]
Dir["out/**/*.gnuplot"].each do |file|
puts "plot #{file}"
name = File.basename(file).split(".").first
cmd = <<-EOF
set terminal pngcairo size 640,480 enhanced
set output '#{File.expand_path File.join("plots", "#{name}.png")}'
#{File.read file}
EOF
f = Tempfile.open("gnuplot")
begin
f.puts cmd
f.close
sh "gnuplot #{f.path}"
ensure
f.unlink
end
end
end
task :build do
sh "docker build . -t ruby-http-benchmark:latest"
end
task :start_docker do
sh "docker run --name ruby-http-benchmark-server -d -p 8811:80 ruby-http-benchmark:latest"
end
task :stop_docker do
sh "docker rm -f ruby-http-benchmark-server"
end