Skip to content

Instantly share code, notes, and snippets.

@rue
Created December 23, 2011 16:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rue/832ccf0b01d488079fdb to your computer and use it in GitHub Desktop.
Save rue/832ccf0b01d488079fdb to your computer and use it in GitHub Desktop.
URI.build
1[22] pry(main)> u = ->() { 10_000.times { uri = URI::HTTP.build :host => "www.example.com", :path => "/foo/bar" } }
=> #<Proc:0x007fd474b2b8f8@(pry):28 (lambda)>
[23] pry(main)> s = ->() { 10_000.times { str = "http://www.example.com/" << "foo/bar" } }
=> #<Proc:0x007fd474b47260@(pry):29 (lambda)>
[24] pry(main)> Benchmark.bmbm {|b| b.report &u; b.report &s };
Rehearsal ------------------------------------
0.510000 0.000000 0.510000 ( 0.507082)
0.010000 0.000000 0.010000 ( 0.014184)
--------------------------- total: 0.520000sec
user system total real
0.500000 0.000000 0.500000 ( 0.502809)
0.010000 0.000000 0.010000 ( 0.006459)
[25] pry(main)>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment