json
json copied to clipboard
Lots of calls to method missing
I'm running on Ruby 1.9.2-p290, using json/ext explicitly. I'm fast generating an array with 600 hashes, 2 keys holding an Integer and a Time object. I ran perftools on the entire stack and I've noticed a lot of calls to method_missing within String.encode. If I'm reading the graph correct, it takes almost 20% of the entire app runtime:
http://cl.ly/1O071A0r2H2F2k1A2004/o
Can I get around this method missing which seems to incur a hefty penalty?
This is the code which triggers the JSON.fast_generate:
class Server < Sinatra::Base
get '/minute/:site_id' do
content_type :json
body JSON.fast_generate(Minute.site params[:site_id].to_i)
end
end