Class: EventShipper::Benchmark
- Inherits:
-
Clamp::Command
- Object
- Clamp::Command
- EventShipper::Benchmark
- Defined in:
- lib/event_shipper/benchmark.rb
Instance Method Summary collapse
- #_receive_message(msg) ⇒ Object
- #_send_message ⇒ Object
- #execute ⇒ Object
-
#initialize(*args) ⇒ Benchmark
constructor
A new instance of Benchmark.
- #measure ⇒ Object
Constructor Details
#initialize(*args) ⇒ Benchmark
Returns a new instance of Benchmark.
7 8 9 10 11 12 13 14 15 |
# File 'lib/event_shipper/benchmark.rb', line 7 def initialize *args super @s = UDP.new('localhost', 5050) @s.wrap Filter::Encrypt.new('user', 'password') @r = UDP.new('localhost', 5050) @r.wrap Filter::Decrypt.new('user' => 'password') end |
Instance Method Details
#_receive_message(msg) ⇒ Object
42 43 44 |
# File 'lib/event_shipper/benchmark.rb', line 42 def msg @r.decode(msg) end |
#_send_message ⇒ Object
36 37 38 39 40 |
# File 'lib/event_shipper/benchmark.rb', line 36 def @s.encode( source: 'benchmark', event: 'this is the event') end |
#execute ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/event_shipper/benchmark.rb', line 17 def execute puts "Simulates 1000 times the sending of a simple message: " measure do 1000.times do end end puts "Simulates 1000 times the receiving of a message: " msg = measure do 1000.times do (msg) end end end |
#measure ⇒ Object
30 31 32 33 34 |
# File 'lib/event_shipper/benchmark.rb', line 30 def measure puts ::Benchmark.measure { yield } end |