unicorn Ruby/Rack server user+dev discussion/patches/pulls/bugs/help
 help / color / Atom feed
9509637598144a100061f400553938886097090e blob 1082 bytes (raw)

 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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
 
# encoding: binary
# benchmark for HTTP parser hackers:
#   make http && ruby -I lib:ext/unicorn_http test/benchmark/http_parser.rb
require 'unicorn'
require 'optparse'
require 'benchmark'
$stdout.sync = true
extra = []
nr = 100000
op = OptionParser.new("", 24, '  ') do |opts|
  opts.banner = "Usage: #$0"
  opts.separator "#$0 options:"
  # some of these switches exist for rackup command-line compatibility,

  opts.on('-n NUM', Integer, 'number of iterations') { |i| nr = i }
  opts.on('-H HEADER:VALUE', String) { |h| extra << h }
  opts.parse! ARGV
end
extra << '' if extra[0]

payload = <<"".freeze
GET /nowhere HTTP/1.0\r
Host: example.com\r
Accept-Encoding: gzip\r
Accept-Language: en-US\r
User-Agent: curl/7.52.1\r
Accept: */*\r
Referer: https://example.com/eye-kant-spel\r
Cache-Control: max-age=0\r
X-Forwarded-For: 0.6.6.6\r
#{extra.join("\r\n")}\r

hp = Unicorn::HttpParser.new
puts payload.gsub(/^/, '> ')
puts "#{nr} iterations"
res = Benchmark.measure do
  nr.times do
    hp.buf << payload
    hp.parse or abort
    hp.clear
  end
end
puts Benchmark::CAPTION, res
debug log:

solving 9509637 ...
found 9509637 in https://bogomips.org/unicorn.git

unicorn Ruby/Rack server user+dev discussion/patches/pulls/bugs/help

Archives are clonable:
	git clone --mirror https://bogomips.org/unicorn-public
	git clone --mirror http://ou63pmih66umazou.onion/unicorn-public

Example config snippet for mirrors

Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.lang.ruby.unicorn
	nntp://ou63pmih66umazou.onion/inbox.comp.lang.ruby.unicorn

 note: .onion URLs require Tor: https://www.torproject.org/

AGPL code for this site: git clone https://public-inbox.org/ public-inbox