Sha256: e30f0dee9beae06d757a3d5d6c64c71883610b22f265a162ddbb62c5cba4e2d1

Contents?: true

Size: 698 Bytes

Versions: 13

Compression:

Stored size: 698 Bytes

Contents

$LOAD_PATH << File.expand_path(File.join(File.dirname(__FILE__), "..", "lib"))

require 'amq/int_allocator'
require "benchmark"

allocator = AMQ::IntAllocator.new(1,65535)
mutex = Mutex.new

Benchmark.bm do |x|


  x.report("allocate") do
    allocator = AMQ::IntAllocator.new(1,65535)
    1.upto(65534) do |i|
      mutex.synchronize do
        n = allocator.allocate
        raise 'it be broke' unless n == i
      end
    end
  end

  x.report("allocate_with_release") do
    allocator = AMQ::IntAllocator.new(1,65535)
    1.upto(65534) do |i|
      mutex.synchronize do
        n = allocator.allocate
        if i % 5 == 0
          allocator.release(n)
        end
      end
    end
  end

end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
amq-protocol-2.3.3 benchmarks/int_allocator.rb
amq-protocol-2.3.2 benchmarks/int_allocator.rb
amq-protocol-2.3.1 benchmarks/int_allocator.rb
amq-protocol-2.3.0 benchmarks/int_allocator.rb
amq-protocol-2.3.0.rc2 benchmarks/int_allocator.rb
amq-protocol-2.3.0.rc1 benchmarks/int_allocator.rb
amq-protocol-2.2.0 benchmarks/int_allocator.rb
amq-protocol-2.1.0 benchmarks/int_allocator.rb
amq-protocol-2.0.1 benchmarks/int_allocator.rb
amq-protocol-2.0.0 benchmarks/int_allocator.rb
amq-protocol-1.9.2 benchmarks/int_allocator.rb
amq-protocol-1.9.1 benchmarks/int_allocator.rb
amq-protocol-1.9.0 benchmarks/int_allocator.rb