Sha256: aafa0e4b86e8df8e49af19d6ae64ff424f33b3c8406d50093c061cd6c8f9e22d
Contents?: true
Size: 960 Bytes
Versions: 3
Compression:
Stored size: 960 Bytes
Contents
#!/usr/bin/env ruby require File.expand_path 'benchmark_helper', File.dirname(__FILE__) class Bench class Foo include EventEmitter end def bench_1on_100Kemit foo = Foo.new count = 0 foo.on :bar do |num| count += num end 100000.times do foo.emit :bar, 1 end raise Error, "test code error" unless count == 100000 end def bench_1Kon_1Kemit foo = Foo.new count = 0 (1000-1).times do foo.on :bar do end end foo.on :bar do |num| count += num end 1000.times do foo.emit :bar, 1 end raise Error, "test code error" unless count == 1000 end def bench_100Kon_1emit foo = Foo.new count = 0 1.upto(100000-1).each do |i| foo.on "bar_#{i}" do end end foo.on :bar do |num| count += num end foo.emit :bar, 1 raise Error, "test code error" unless count == 1 end end if __FILE__ == $0 Bench.run end
Version data entries
3 entries across 3 versions & 2 rubygems
Version | Path |
---|---|
event_emitter-0.2.6 | benchmark/benchmark.rb |
event_emitter-with_instance_listener-0.2.5 | benchmark/benchmark.rb |
event_emitter-0.2.5 | benchmark/benchmark.rb |