Sha256: a6a45b4d7bba85f794058eaf865212f9939a41921c96339f3fe6b949f5f3ee33

Contents?: true

Size: 764 Bytes

Versions: 12

Compression:

Stored size: 764 Bytes

Contents

#!/usr/bin/env ruby
# frozen_string_literal: true

require_relative 'setup'

records = FrozenRecord::Backends::Yaml.load(Country.file_path)
large_records = 100.times.flat_map do |i|
  records.map do |record|
    new_record = record.dup
    new_record['id'] += 10 * i
    new_record['name'] += i.to_s
    new_record
  end
end

File.write('/tmp/frozen-record-bench-countries.yml', YAML.dump(large_records))

class LargeCountry < Country
  class << self
    def file_path
      '/tmp/frozen-record-bench-countries.yml'
    end
  end
end

puts "=== simple scalar match ==="
Benchmark.ips do |x|
  x.report('simple') { LargeCountry.nato.size }
end

puts "=== range match ==="
Benchmark.ips do |x|
  x.report('range') { LargeCountry.where(density: 100...200).size }
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
frozen_record-0.26.0 benchmark/querying
frozen_record-0.25.5 benchmark/querying
frozen_record-0.25.4 benchmark/querying
frozen_record-0.25.3 benchmark/querying
frozen_record-0.25.2 benchmark/querying
frozen_record-0.25.1 benchmark/querying
frozen_record-0.25.0 benchmark/querying
frozen_record-0.24.1 benchmark/querying
frozen_record-0.23.0 benchmark/querying
frozen_record-0.22.2 benchmark/querying
frozen_record-0.22.1 benchmark/querying
frozen_record-0.22.0 benchmark/querying