summaryrefslogtreecommitdiff
path: root/test/fiber/http.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/fiber/http.rb')
-rw-r--r--test/fiber/http.rb11
1 files changed, 6 insertions, 5 deletions
diff --git a/test/fiber/http.rb b/test/fiber/http.rb
index ad51ae3..53a4602 100644
--- a/test/fiber/http.rb
+++ b/test/fiber/http.rb
@@ -15,24 +15,25 @@ def fetch_topics(topics)
topics.each do |topic|
Fiber.new(blocking: Fiber.current.blocking?) do
uri = URI("https://www.google.com/search?q=#{topic}")
- responses[topic] = Net::HTTP.get(uri).scan(topic).size
+ response = Net::HTTP.get(uri)
+ responses[topic] = response.scan(topic).size
end.resume
end
- Thread.fiber_scheduler&.run
+ Fiber.scheduler&.run
return responses
end
def sweep(repeats: 3, **options)
times = (1..8).map do |i|
- $stderr.puts "Measuring #{i} topic(s)..."
+ $stderr.puts "Measuring #{i} topic(s) #{options.inspect}..."
topics = TOPICS[0...i]
Thread.new do
Benchmark.realtime do
scheduler = Scheduler.new
- Fiber.set_scheduler scheduler
+ Fiber.set_scheduler(scheduler)
repeats.times do
Fiber.new(**options) do
@@ -49,5 +50,5 @@ def sweep(repeats: 3, **options)
puts JSON.dump(times.map{|value| value.round(3)})
end
-sweep(blocking: true)
+# sweep(blocking: true)
sweep(blocking: false)