Skip to content

Instantly share code, notes, and snippets.

@shikendon
Last active August 23, 2022 11:53
Show Gist options
  • Save shikendon/b9c0e0041c8cec11e3f6bbe9fa987c0b to your computer and use it in GitHub Desktop.
Save shikendon/b9c0e0041c8cec11e3f6bbe9fa987c0b to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require "benchmark"
require "httparty"
require "parallel"
# You need to modify your open file limit
# if you trying to run this on Mac OS
Benchmark.bmbm do |x|
x.report("Ruby Thread.new") do
threads = []
1000.times do
threads << Thread.new do
_response = HTTParty.get("https://www.facebook.com/")
end
end
threads.map(&:join)
end
x.report("Ruby Parallel") do
Parallel.each(1..1000, in_threads: 1000) do
_response = HTTParty.get("https://www.facebook.com/")
end
end
x.report("Python threading") do
`python3 threading_test.py`
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment