Skip to content

Instantly share code, notes, and snippets.

@mykoweb
Created December 20, 2016 00:38
Show Gist options
  • Save mykoweb/abebce476d27002b1b1156a1f8d5724c to your computer and use it in GitHub Desktop.
Save mykoweb/abebce476d27002b1b1156a1f8d5724c to your computer and use it in GitHub Desktop.

Revisions

  1. mykoweb created this gist Dec 20, 2016.
    18 changes: 18 additions & 0 deletions io_bound.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,18 @@
    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