Skip to content

Instantly share code, notes, and snippets.

@effektz
Last active August 29, 2015 14:12
Show Gist options
  • Save effektz/f18e1be522a328a981b9 to your computer and use it in GitHub Desktop.
Save effektz/f18e1be522a328a981b9 to your computer and use it in GitHub Desktop.

Code

Benchmark.ips do |x|
  x.time = 10
  x.report("Special#first") do
    Special.first
  end;1
  x.report("Special#where") do
    Special.where(id: 255)
  end;1
  x.report("Special#find") do
    Special.find(500)
  end;1
  x.report("Special#find_by_slug") do
    Special.find_by_slug("aced-31090cae-0a26-454b-981f-c4c9209a8408")
  end;1
end;1

Data

10,000 Specials

#<Special:0x007fb43521ef80
 id: 1,
 name: "abc",
 body: "",
 featured: false,
 on_hold: false,
 created_at: Thu, 01 Jan 2015 04:20:12 UTC +00:00,
 updated_at: Thu, 01 Jan 2015 07:10:42 UTC +00:00,
 deleted_at: nil>

No gems

  • Special#first - 2.0k (± 7.6%) i/s
  • Special#where - 27.7k (±12.3%) i/s
  • Special#find - 3.6k (± 9.1%) i/s
  • Special#find_by_slug - 542.4 (± 4.2%) i/s

With paranoid2 (default scope)

  • Special#first - 1.5k (± 6.9%) i/s
  • Special#where - 9.4k (± 9.7%) i/s
  • Special#find - 1.7k (± 7.6%) i/s
  • Special#find_by_slug - 442.7 (± 5.0%) i/s

With paranoid42 (no default scope)

  • Special#first - 1.8k (± 7.3%) i/s
  • Special#where - 18.5k (±14.2%) i/s
  • Special#find - 2.0k (± 8.6%) i/s
  • Special#find_by_slug - 464.0 (± 4.3%) i/s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment