public
Description: A very fast & simple Ruby web server
Homepage: http://code.macournoyer.com/thin/
Clone URL: git://github.com/macournoyer/thin.git
thin / script / profile
100755 23 lines (20 sloc) 0.545 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/usr/bin/env ruby
# Script to profile thin using ruby-prof.
# Takes the same arguments as the thin script.
require 'rubygems'
require 'ruby-prof'
require File.dirname(__FILE__) + '/../lib/thin'
 
class Adapter
  def call(env)
    [200, {'Content-Type' => 'text/html', 'Content-Length' => '11'}, ['hello world']]
  end
end
 
# Profile the code
result = RubyProf.profile do
  Thin::Server.start('0.0.0.0', 3000) do
    run Adapter.new
  end
end
 
# Print a graph profile to text
printer = RubyProf::GraphPrinter.new(result)
printer.print(STDOUT, 0)