Sha256: 03a8d90042217b392119552ac5460ce41a44c6dba83d64b97fc67443ebc95691

Contents?: true

Size: 796 Bytes

Versions: 25

Compression:

Stored size: 796 Bytes

Contents

# frozen_string_literal: true
require 'dynflow'
require 'benchmark'

class Receiver
  def initialize(limit, future)
    @limit = limit
    @future = future
    @counter = 0
  end

  def null
    @counter += 1
    @future.fulfill(true) if @counter >= @limit
  end
end

def test_case(count)
  future   = Concurrent::Promises.resolvable_future
  clock    = Dynflow::Clock.spawn(:name => 'clock')
  receiver = Receiver.new(count, future)

  count.times do
    clock.ping(receiver, 0, nil, :null)
  end
  future.wait
end

Benchmark.bm do |bm|
  bm.report('   100') { test_case 100 }
  bm.report('  1000') { test_case 1_000 }
  bm.report('  5000') { test_case 5_000 }
  bm.report(' 10000') { test_case 10_000 }
  bm.report(' 50000') { test_case 50_000 }
  bm.report('100000') { test_case 100_000 }
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
dynflow-1.8.2 examples/clock_benchmark.rb
dynflow-1.8.1 examples/clock_benchmark.rb
dynflow-1.8.0 examples/clock_benchmark.rb
dynflow-1.7.0 examples/clock_benchmark.rb
dynflow-1.6.11 examples/clock_benchmark.rb
dynflow-1.6.10 examples/clock_benchmark.rb
dynflow-1.6.8 examples/clock_benchmark.rb
dynflow-1.6.7 examples/clock_benchmark.rb
dynflow-1.6.6 examples/clock_benchmark.rb
dynflow-1.6.5 examples/clock_benchmark.rb
dynflow-1.6.4 examples/clock_benchmark.rb
dynflow-1.6.3 examples/clock_benchmark.rb
dynflow-1.6.2 examples/clock_benchmark.rb
dynflow-1.6.1 examples/clock_benchmark.rb
dynflow-1.4.9 examples/clock_benchmark.rb
dynflow-1.4.8 examples/clock_benchmark.rb
dynflow-1.5.0 examples/clock_benchmark.rb
dynflow-1.4.7 examples/clock_benchmark.rb
dynflow-1.4.6 examples/clock_benchmark.rb
dynflow-1.4.5 examples/clock_benchmark.rb