Sha256: 8aad895719a6cddaf7ff02cc96c074453b4ec35aeb5828d1d18df489d7dd5873

Contents?: true

Size: 797 Bytes

Versions: 2

Compression:

Stored size: 797 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

2 entries across 2 versions & 1 rubygems

Version Path
dynflow-1.9.0 examples/clock_benchmark.rb
dynflow-1.8.3 examples/clock_benchmark.rb