Skip to content

Instantly share code, notes, and snippets.

@asterite
Created March 12, 2015 17:41
Show Gist options
  • Save asterite/4affe315f7dd222f9ecd to your computer and use it in GitHub Desktop.
Save asterite/4affe315f7dd222f9ecd to your computer and use it in GitHub Desktop.
require "benchmark"
require "http/client"
def get(url)
HTTP::Client.get(url)
end
Benchmark.bm do |x|
x.report("sync") do
get("http://www.google.com")
get("http://www.google.com")
get("http://www.google.com")
get("http://www.google.com")
get("http://www.google.com")
get("http://www.google.com")
get("http://www.google.com")
get("http://www.google.com")
get("http://www.google.com")
end
x.report("parallel") do
parallel(
get("http://www.google.com"),
get("http://www.google.com"),
get("http://www.google.com"),
get("http://www.google.com"),
get("http://www.google.com"),
get("http://www.google.com"),
get("http://www.google.com"),
get("http://www.google.com"),
get("http://www.google.com"),
)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment