Skip to content

Instantly share code, notes, and snippets.

@sergey-alekseev
Created March 21, 2015 21:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sergey-alekseev/afc81edde050fadd3e91 to your computer and use it in GitHub Desktop.
Save sergey-alekseev/afc81edde050fadd3e91 to your computer and use it in GitHub Desktop.
Benchmark.ips do |x|
x.report('exists?') { User.exists?(:id => 1) }
x.report('where-any?') { User.where(:id => 1).any? }
x.compare!
end
Comparison:
exists?: 636.0 i/s
where-any?: 567.1 i/s - 1.12x slower
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment