Sha256: 3fd0f5292897fb640f282b20a986c802b9c52bb21c7cc517a742c323264f948d

Contents?: true

Size: 756 Bytes

Versions: 16

Compression:

Stored size: 756 Bytes

Contents

# frozen_string_literal: true

require "rubygems"
require "benchmark"

require_relative "cache_runner"

RUNS = 400

class ARCreator
  include ActiveRecordObjects
end

def run(obj)
  obj.prepare
  GC.start
  Benchmark.measure do
    obj.run
  end
ensure
  obj.cleanup
end

def benchmark(runners, label_width = 0)
  IdentityCache.cache.clear
  runners.each do |runner|
    print("#{runner.name}: ".ljust(label_width))
    puts run(runner.new(RUNS))
  end
end

def bmbm(runners)
  label_width = runners.map { |r| r.name.size }.max + 2
  width = label_width + Benchmark::CAPTION.size

  puts "Rehearsal: ".ljust(width, "-")
  benchmark(runners, label_width)
  puts "-" * width

  benchmark(runners, label_width)
end

create_database(RUNS)

bmbm(CACHE_RUNNERS)

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
identity_cache-1.6.3 performance/cpu.rb
identity_cache-1.6.2 performance/cpu.rb
identity_cache-1.6.1 performance/cpu.rb
identity_cache-1.6.0 performance/cpu.rb
identity_cache-1.5.6 performance/cpu.rb
identity_cache-1.5.5 performance/cpu.rb
identity_cache-1.5.4 performance/cpu.rb
identity_cache-1.5.3 performance/cpu.rb
identity_cache-1.5.2 performance/cpu.rb
identity_cache-1.5.1 performance/cpu.rb
identity_cache-1.5.0 performance/cpu.rb
identity_cache-1.4.1 performance/cpu.rb
identity_cache-1.4.0 performance/cpu.rb
identity_cache-1.3.1 performance/cpu.rb
identity_cache-1.3.0 performance/cpu.rb
identity_cache-1.2.0 performance/cpu.rb