Skip to content

Instantly share code, notes, and snippets.

@murajun1978
Created September 11, 2014 13:22
Show Gist options
  • Save murajun1978/f71dd61373461256b5d7 to your computer and use it in GitHub Desktop.
Save murajun1978/f71dd61373461256b5d7 to your computer and use it in GitHub Desktop.
posts = Post.all
Benchmark.bm do |x|
x.report(:exists) {posts.exists?}
x.report(:present) {posts.present?}
end
user system total real
Post Exists (0.3ms) SELECT 1 AS one FROM "posts" LIMIT 1
exists 0.020000 0.000000 0.020000 ( 0.028894)
present 0.000000 0.000000 0.000000 ( 0.000018)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment