summaryrefslogtreecommitdiff
path: root/test/fiber/http.rb
diff options
context:
space:
mode:
authorSamuel Williams <samuel.williams@oriontransfer.co.nz>2021-02-09 19:39:56 +1300
committerGitHub <noreply@github.com>2021-02-09 19:39:56 +1300
commit5f69a7f60467fa58c2f998daffab43e118bff36c (patch)
treef60e3a5add29eb9cc7e68433c4e373e2a2facab7 /test/fiber/http.rb
parent3c593f28ede99b77d4fe3258f9bda78dcee238a3 (diff)
Expose scheduler as public interface & bug fixes. (#3945)
* Rename `rb_scheduler` to `rb_fiber_scheduler`. * Use public interface if available. * Use `rb_check_funcall` where possible. * Don't use `unblock` unless the fiber was non-blocking.
Notes
Notes: Merged-By: ioquatix <samuel@codeotaku.com>
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 ad51ae3c769..53a4602bd45 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)