Created
January 2, 2020 16:33
-
-
Save rossta/cc8f547dfe4967c8c2c67e36b1f24414 to your computer and use it in GitHub Desktop.
Comparing open from disk to open-uri
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "benchmark" | |
require "open-uri" | |
require "pathname" | |
n = 1_000 | |
Benchmark.bm do |benchmark| | |
benchmark.report("open(url).read") do | |
n.times do | |
open("http://localhost:3035/packs/manifest.json").read | |
end | |
end | |
benchmark.report("Pathname.new(path).read") do | |
n.times do | |
Pathname.new("./public/packs/manifest.json").read | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
On my machine (MacBook Pro, 15", mid 2014, 2.8 GHz Quad-Core Intel Core i7):