Sha256: 970c0e4c18a620de0676ac5ef5b2ad2d7954ecc52c68b7e73936a512d3d186ff

Contents?: true

Size: 710 Bytes

Versions: 1

Compression:

Stored size: 710 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
  BenchClass.new()
  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

1 entries across 1 versions & 1 rubygems

Version Path
simple_model-1.2.22 benchmarks/simple_model.rb