File: profile

package info (click to toggle)
thin 1.8.2%2Bgit20250216.de6b618-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,320 kB
  • sloc: javascript: 6,108; ruby: 5,147; ansic: 1,738; sh: 21; makefile: 8
file content (25 lines) | stat: -rwxr-xr-x 566 bytes parent folder | download | duplicates (2)
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)