Skip to content

Instantly share code, notes, and snippets.

@artkirienko
Forked from mykoweb/io_bound.rb
Created February 10, 2017 10:21
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 artkirienko/75f83bad27a4454746655397df6b2c08 to your computer and use it in GitHub Desktop.
Save artkirienko/75f83bad27a4454746655397df6b2c08 to your computer and use it in GitHub Desktop.
require 'faraday'
require 'benchmark'
@conn = Faraday.new(url: 'https://www.google.com')
@threads = []
Benchmark.bm(14) do |x|
x.report('no-threads') do
8.times { @conn.get }
end
x.report('with-threads') do
8.times do
@threads << Thread.new { @conn.get }
end
@threads.each(&:join)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment