Created
July 8, 2011 19:26
-
-
Save nesquena/1072608 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'benchmark' | |
require 'active_support/all' | |
require 'httparty' | |
HOST = "http://listify-it.herokuapp.com" | |
def benchy(name, count=5) | |
result = Benchmark.realtime { count.times { HTTParty.get("#{HOST}/debug/#{name}") } } / count.to_f | |
"#{(result * 1000).round} ms average" | |
end | |
def bench_it(name, count=5) | |
benchy(name, count) # Warmup | |
3.times.map { benchy(name, count) }.inspect | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
######################################## | |
# RESULTS | |
# bench_it(to_json) - ["33 ms average", "24 ms average", "36 ms average"] | |
# bench_it(rabl1) - ["36 ms average", "23 ms average", "43 ms average"] | |
# bench_it(rabl2) - ["41 ms average", "45 ms average", "42 ms average"] | |
######################################## | |
get :to_json do | |
@lists = List.recent.includes(:users).limit(15) | |
@lists.to_json | |
end | |
get :rabl1 do | |
@lists = List.recent.includes(:users).limit(15) | |
render "lists/small" | |
end | |
get :rabl2 do | |
@lists = List.recent.includes(:users).limit(15) | |
render "lists/medium" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For 'medium' we purposely used extends and partial and added a lot more attributes to measure the performance impact