Created
July 13, 2011 18:47
-
-
Save deepthawtz/1080995 to your computer and use it in GitHub Desktop.
this is something I see people do a lot
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 "rubygems" | |
require "benchmark" | |
require "action_view" | |
obj = { | |
:stuff => %w[ ant bee cat dog eel fly gnu ], | |
:yeah => { | |
:nacho => "cheese" | |
}, | |
:junk => [12,2312,223,33,434,45,454,345345,213,32,32,45,45,54,45,456,56,56,234,34,34,56,56,56,56,56,5677,567,234,34,234,345,345,435,345,3456] | |
} | |
av = ActionView::Base.new | |
N = 30_000 | |
Benchmark.bmbm do |x| | |
x.report("render :json => obj ") do | |
N.times do | |
av.render :json => obj | |
end | |
end | |
x.report("render :json => obj.to_json") do | |
N.times do | |
av.render :json => obj.to_json | |
end | |
end | |
end | |
__END__ | |
Rehearsal --------------------------------------------------------------- | |
render :json => obj 0.210000 0.010000 0.220000 ( 0.217348) | |
render :json => obj.to_json 21.300000 0.070000 21.370000 ( 21.368202) | |
----------------------------------------------------- total: 21.590000sec | |
user system total real | |
render :json => obj 0.210000 0.000000 0.210000 ( 0.214650) | |
render :json => obj.to_json 20.880000 0.070000 20.950000 ( 20.949253) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment