Skip to content
Browse files

add profiling script

  • Loading branch information...
1 parent 41e7d91 commit d34d0af99fd13c16a155d0f6fb5575ee53e246d5 @jonasschneider committed
Showing with 24 additions and 0 deletions.
  1. +1 −0 .gitignore
  2. +23 −0 perf/profile.rb
View
1 .gitignore
@@ -2,3 +2,4 @@
.bundle
Gemfile.lock
pkg/*
+perf/profile.html
View
23 perf/profile.rb
@@ -0,0 +1,23 @@
+require "ruby-prof"
+
+require File.expand_path("../../spec/support/helpers", __FILE__)
+require File.expand_path("../../spec/support/blocking_spdy_client", __FILE__)
+require "momentum"
+require "em-synchrony"
+
+app = lambda { |env| [200, {"Content-Type" => "text/plain"}, ['text']] }
+
+EM.synchrony do
+ Momentum.start(Momentum::Backend.new(app))
+ c = BlockingSPDYClient.new('localhost', 5555)
+
+ res = RubyProf.profile do
+ c.request '/'
+ 3.times do
+ c.read_packet
+ end
+ end
+
+ printer = RubyProf::GraphHtmlPrinter.new(res)
+ printer.print(File.open(File.expand_path("../profile.html", __FILE__), 'w'), {})
+end

0 comments on commit d34d0af

Please sign in to comment.
Something went wrong with that request. Please try again.