Sha256: bf152faf2e5fad2058b0239cc99f47922871591c75fa9f29f6be4923a65a4b73

Contents?: true

Size: 1.68 KB

Versions: 10

Compression:

Stored size: 1.68 KB

Contents

#!/usr/bin/env ruby -KU
require File.dirname(__FILE__) + '/extras'
require 'rbench'
FACTOR = 100
RBench.run(TIMES) do

  column :times
  column :ar

  report 'find model using id', (TIMES * FACTOR).ceil do
    ar { User.find(get_id) }
  end

  report 'find model using array of ids', (TIMES * FACTOR).ceil do
    ar { User.find([get_id, get_id]) }
  end

  report 'find unslugged model using friendly id', (TIMES * FACTOR).ceil do
    ar { User.find(USERS.rand) }
  end

  report 'find unslugged model using array of friendly ids', (TIMES * FACTOR).ceil do
    ar { User.find([USERS.rand, USERS.rand]) }
  end

  report 'find slugged model using friendly id', (TIMES * FACTOR).ceil do
    ar { Post.find(POSTS.rand) }
  end

  report 'find slugged model using array of friendly ids', (TIMES * FACTOR).ceil do
    ar { Post.find([POSTS.rand, POSTS.rand]) }
  end

  report 'find cached slugged model using friendly id', (TIMES * FACTOR).ceil do
    ar { District.find(DISTRICTS.rand) }
  end

  report 'find cached slugged model using array of friendly ids', (TIMES * FACTOR).ceil do
    ar { District.find([DISTRICTS.rand, DISTRICTS.rand]) }
  end

  report 'find model using id, then to_param', (TIMES * FACTOR).ceil do
    ar { User.find(get_id).to_param }
  end

  report 'find unslugged model using friendly id, then to_param', (TIMES * FACTOR).ceil do
    ar { User.find(USERS.rand).to_param }
  end

  report 'find slugged model using friendly id, then to_param', (TIMES * FACTOR).ceil do
    ar { Post.find(POSTS.rand).to_param }
  end

  report 'find cached slugged model using friendly id, then to_param', (TIMES * FACTOR).ceil do
    ar { District.find(DISTRICTS.rand).to_param }
   end

  summary 'Total'
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
friendly_id-3.0.1 extras/bench.rb
friendly_id-3.0.0 extras/bench.rb
friendly_id-3.0.0.beta3 extras/bench.rb
friendly_id-3.0.0.beta2 extras/bench.rb
friendly_id-3.0.0.beta1 extras/bench.rb
friendly_id-2.3.4 extras/bench.rb
friendly_id-2.3.3 extras/bench.rb
friendly_id-2.3.2 extras/bench.rb
friendly_id-2.3.1 extras/bench.rb
friendly_id-2.3.0 extras/bench.rb