Sha256: 1bfb52a256e8e2ef49e6491518e579fc8d289f1a37bd02fdec7302482a7e7544
Contents?: true
Size: 925 Bytes
Versions: 12
Compression:
Stored size: 925 Bytes
Contents
#!/usr/bin/env ruby $LOAD_PATH << File.expand_path("../../lib", __dir__) require 'async/reactor' require 'async/io/host_endpoint' require 'async/container' require 'async/container/forked' endpoint = Async::IO::Endpoint.parse(ARGV.pop || "tcp://localhost:7234") CONNECTIONS = 1_000_000 CONCURRENCY = Async::Container.hardware_concurrency TASKS = 16 REPEATS = (CONNECTIONS.to_f / (TASKS * CONCURRENCY)).ceil puts "Starting #{CONCURRENCY} processes, running #{TASKS} tasks, making #{REPEATS} connections." puts "Total number of connections: #{CONCURRENCY * TASKS * REPEATS}!" begin container = Async::Container::Forked.new container.run(count: CONCURRENCY) do Async do |task| connections = [] TASKS.times do task.async do REPEATS.times do $stdout.write "." connections << endpoint.connect end end end end end container.wait ensure container.stop if container end
Version data entries
12 entries across 12 versions & 1 rubygems