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