cloudride
8/4/2014 - 4:22 PM

Ruby performance testing (using Benchmark)

Ruby performance testing (using Benchmark)

  def self.test limit = 10
   results = Entry.where(date: '2014-01-14').last(limit)
   Benchmark.bm do |bm|
     bm.report('new') do
       results.map do |entry|
         self.detect_model_new entry
       end
     end
     bm.report('old') do
       results.map do |entry|
         self.detect_model entry
       end
     end
   end
   nil
  end