Skip to content

Commit 5d4d72c

Browse files
committed
also bench a topic page
1 parent d753cdb commit 5d4d72c

1 file changed

Lines changed: 22 additions & 14 deletions

File tree

script/bench.rb

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,10 @@ def port_available? port
6666
false
6767
end
6868

69-
port = 60079
69+
@port = 60079
7070

71-
while !port_available? port
72-
port += 1
71+
while !port_available? @port
72+
@port += 1
7373
end
7474

7575
puts "Ensuring profiling DB exists and is migrated"
@@ -84,27 +84,35 @@ def port_available? port
8484
puts "Populating Profile DB"
8585
run("bundle exec ruby script/profile_db_generator.rb")
8686

87-
begin
88-
pid = spawn("bundle exec thin start -p #{port}")
89-
90-
while port_available? port
91-
sleep 1
92-
end
93-
87+
def bench(path)
9488
puts "Running apache bench warmup"
95-
`ab -n 100 http://localhost:#{port}/`
96-
puts "Benchmarking front page"
97-
`ab -n 100 -e tmp/ab.csv http://localhost:#{port}/`
89+
`ab -n 100 http://localhost:#{@port}#{path}`
90+
puts "Benchmarking #{path}"
91+
`ab -n 100 -e tmp/ab.csv http://localhost:#{@port}#{path}`
9892

9993
percentiles = Hash[*[50, 75, 90, 99].zip([]).flatten]
10094
CSV.foreach("tmp/ab.csv") do |percent, time|
10195
percentiles[percent.to_i] = time.to_i if percentiles.key? percent.to_i
10296
end
10397

98+
percentiles
99+
end
100+
101+
begin
102+
pid = spawn("bundle exec thin start -p #{@port}")
103+
104+
while port_available? @port
105+
sleep 1
106+
end
107+
108+
home_page = bench("/")
109+
topic_page = bench("/t/oh-how-i-wish-i-could-shut-up-like-a-tunnel-for-so/69")
110+
104111
puts "Your Results:"
105112

106113
puts({
107-
"home_page" => percentiles,
114+
"home_page" => home_page,
115+
"topic_page" => topic_page,
108116
"timings" => @timings
109117
}.to_yaml)
110118

0 commit comments

Comments
 (0)