Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

add profiling to bench

  • Loading branch information...
commit 5e48fb23ec64a0091cf2b7c923ff24d9c22d95c2 1 parent c5fa5e7
Blake Mizerany bmizerany authored
Showing with 23 additions and 13 deletions.
  1. +1 −0  .gitignore
  2. +22 −13 bench/gets.rb
1  .gitignore
View
@@ -2,3 +2,4 @@
.bundle
Gemfile.lock
pkg/*
+*.prof*
35 bench/gets.rb
View
@@ -1,32 +1,41 @@
require 'rubygems'
+require 'perftools'
require 'eventmachine'
require 'fraggle'
+ENV['CPUPROFILE_FREQUENCY'] = '4000'
+
reqs = 0
+prof = ARGV[0]
-def rget(c, rev, path, &blk)
+def rget(c, count, rev, path, &blk)
c.get(rev, path) do |e|
- blk.call
- rget(c, rev, path, &blk)
+ if count == 0
+ blk.call
+ end
+
+ rget(c, count-1, rev, path, &blk)
end
end
EM.run do
c = Fraggle.connect
- EM.add_timer(1) do
- # The primer is done. Reset `reqs` and do it for real.
- reqs = 0
- EM.add_timer(1) do
- EM.stop_event_loop
- end
+ if prof
+ PerfTools::CpuProfiler.start("fraggle-gets.prof")
end
c.rev do |v|
- rget(c, v.rev, "/ctl/cal/0") do
- reqs += 1
+ start = Time.now
+ rget(c, 100_000, v.rev, "/ctl/cal/0") do
+ if prof
+ PerfTools::CpuProfiler.stop
+ `pprof.rb fraggle-gets.prof --gif > fraggle-gets.prof.gif`
+ end
+
+ EM.stop_event_loop
+
+ puts "Time: #{Time.now - start}"
end
end
end
-
-puts "Result (GET): #{reqs}/sec"
Please sign in to comment.
Something went wrong with that request. Please try again.