Sha256: 37b8540c1139dcd3b263b188906e70e0cb9007ed139cc3253e9541f4da9cd02d

Contents?: true

Size: 927 Bytes

Versions: 5

Compression:

Stored size: 927 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(concurrency: CONCURRENCY) do
		Async::Reactor.run 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

5 entries across 5 versions & 1 rubygems

Version Path
async-io-1.18.2 examples/millions/client.rb
async-io-1.18.1 examples/millions/client.rb
async-io-1.17.2 examples/millions/client.rb
async-io-1.17.1 examples/millions/client.rb
async-io-1.16.4 examples/millions/client.rb