Skip to content

Instantly share code, notes, and snippets.

@tarcieri
Created March 11, 2012 04:03
Show Gist options
  • Save tarcieri/2014969 to your computer and use it in GitHub Desktop.
Save tarcieri/2014969 to your computer and use it in GitHub Desktop.
Puma parser benchmark
require 'rubygems'
require 'puma'
require 'benchmark/ips'
request = <<-REQUEST
GET / HTTP/1.1
Host: www.example.com
Connection: keep-alive
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_3) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.78 Safari/535.11
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3
REQUEST
request.gsub!(/\n/m, "\r\n")
Benchmark.ips do |ips|
ips.report("instance") { Puma::HttpParser.new }
ips.report("parsing") do
parser = Puma::HttpParser.new
headers = {}
parser.execute headers, request, 0
end
end
╭─tony@wintermute ~ ‹ruby-1.9.3›
╰─$ ruby puma_parser_benchmark.rb
instance 773934.9 (±6.0%) i/s - 3862400 in 5.007993s (cycle=38624)
parsing 126609.6 (±7.1%) i/s - 639406 in 5.074865s (cycle=10313)
╭─tony@wintermute ~ ‹jruby-head›
╰─$ ruby puma_parser_benchmark.rb
instance 1545307.1 (±3.8%) i/s - 7690144 in 4.984386s (cycle=43694)
parsing 81442.3 (±2.8%) i/s - 409772 in 5.035544s (cycle=6116)
╭─tony@wintermute ~ ‹jruby-1.6.7›
╰─$ ruby puma_parser_benchmark.rb
instance 1622726.1 (±5.7%) i/s - 8062450 in 4.988103s (cycle=29425)
parsing 71185.1 (±2.9%) i/s - 360112 in 5.063237s (cycle=5072)
╭─tony@wintermute ~ ‹rbx-head›
╰─$ ruby puma_parser_benchmark.rb
instance 544165.3 (±40.1%) i/s - 1790504 in 5.025805s (cycle=19462)
parsing 33190.5 (±13.9%) i/s - 162781 in 5.006371s (cycle=2759)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment