Sha256: 5eb9d712f9ec38f93049ad434bea1033e270695b9cb69b09c09af074d8955097

Contents?: true

Size: 1.23 KB

Versions: 53

Compression:

Stored size: 1.23 KB

Contents

require "bundler/gem_tasks"
require "rspec/core/rake_task"

RSpec::Core::RakeTask.new(:test)

task :default => :test

task :server do
	require 'async/reactor'
	require 'async/http/server'
	
	app = lambda do |env|
		[200, {}, ["Hello World"]]
	end

	server = Async::HTTP::Server.new([
		Async::IO::Endpoint.tcp('127.0.0.1', 9294, reuse_port: true)
	], app)

	Async::Reactor.run do
		server.run
	end
end

task :client do
	require 'async/reactor'
	require 'async/http/client'
	
	client = Async::HTTP::Client.new([
		Async::IO::Endpoint.tcp('127.0.0.1', 9294, reuse_port: true)
	])
	
	Async::Reactor.run do
		response = client.get("/")
		
		puts response.inspect
	end
end

task :wrk do
	require 'async/reactor'
	require 'async/http/server'
	
	app = lambda do |env|
		[200, {}, ["Hello World"]]
	end

	server = Async::HTTP::Server.new([
		Async::IO::Endpoint.tcp('127.0.0.1', 9294, reuse_port: true)
	], app)

	process_count = Etc.nprocessors

	pids = process_count.times.collect do
		fork do
			Async::Reactor.run do
				server.run
			end
		end
	end

	url = "http://127.0.0.1:9294/"
	
	connections = process_count
	system("wrk", "-c", connections.to_s, "-d", "2", "-t", connections.to_s, url)

	pids.each do |pid|
		Process.kill(:KILL, pid)
		Process.wait pid
	end
end

Version data entries

53 entries across 53 versions & 3 rubygems

Version Path
async-http-faraday-0.7.0 Rakefile
async-http-faraday-0.6.0 Rakefile
async-http-faraday-0.5.1 Rakefile
async-http-faraday-0.5.0 Rakefile
async-http-faraday-0.4.0 Rakefile
async-http-faraday-0.3.0 Rakefile
async-http-faraday-0.2.0 Rakefile
falcon-0.18.13 Rakefile
falcon-0.18.12 Rakefile
falcon-0.18.11 Rakefile
falcon-0.18.10 Rakefile
falcon-0.18.9 Rakefile
falcon-0.18.8 Rakefile
falcon-0.18.7 Rakefile
falcon-0.18.6 Rakefile
falcon-0.18.5 Rakefile
falcon-0.18.4 Rakefile
falcon-0.18.3 Rakefile
falcon-0.18.2 Rakefile
falcon-0.18.1 Rakefile