File: profile

package info (click to toggle)
thin 1.2.4-1.1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 1,252 kB
  • ctags: 531
  • sloc: ruby: 4,529; ansic: 725; sh: 21; makefile: 16
file content (25 lines) | stat: -rwxr-xr-x 566 bytes parent folder | download | duplicates (3)
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
#!/usr/bin/env ruby
# Script to profile thin using ruby-prof.
# Takes the same arguments as the thin script.
require 'rubygems'
require 'ruby-prof'

$: << File.join(File.dirname(__FILE__), '..', 'lib')
require '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)