Sha256: 6f0334176abaa2ee2e94a1c2e786c4503b51c6c36fd0e8f4aa46f0e02dce5bd2

Contents?: true

Size: 693 Bytes

Versions: 2

Compression:

Stored size: 693 Bytes

Contents

class BenchClass < SimpleModel::Base
  has_int :num
  has_date :date, :default => :today
  has_decimal :dec

  def today
    Date.today
  end
end
Benchmark.bm do |b|
  b.report("initialize") do
    30000.times.each  do
      BenchClass.new()
    end
  end

  b.report("initialize with attrs") do
    30000.times.each  do
      BenchClass.new(:num => 1, :dec => "12.4")
    end
  end

  b.report("get") do
    30000.times.each  do
      klass = BenchClass.new
      klass.num
      klass.dec
      klass.date
    end
  end

  b.report("set") do
    30000.times.each  do
      klass = BenchClass.new
      klass.num = 1
      klass.dec = '12.4'
      klass.date = "2014-12-25"
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
simple_model-1.2.26 benchmarks/simple_model.rb
simple_model-1.2.25 benchmarks/simple_model.rb