Skip to content

Instantly share code, notes, and snippets.

@irridescentrambler
Last active March 9, 2026 08:00
Show Gist options
  • Select an option

  • Save irridescentrambler/1f9a89cc07c2fbacda8b93eec7aa4865 to your computer and use it in GitHub Desktop.

Select an option

Save irridescentrambler/1f9a89cc07c2fbacda8b93eec7aa4865 to your computer and use it in GitHub Desktop.
require 'net/http'
require 'uri'
require 'async'
require 'benchmark'
bm = Benchmark.measure("Asynchronous flow") do
Async do
results = 21.times.map do |url|
Async do
Net::HTTP.get_response(URI("https://dog.ceo/api/breeds/image/random"),)
end
end
results.each do |response|
puts response.wait.body
end
end
end
puts bm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment