On Jan 27, 6:26 am, Claudio Poli <[email protected]> wrote:

>     1.9.3p0 :001 > MultiJson.engine
>      => MultiJson::Engines::Yajl
>
> The key issue here is that with a large Hash the render action takes
> 36786ms to finish ( of which 8253.6ms spent for the database query,
> that high because of multiple ORDER BY, that's another matter).
>
> So I tried another way:
>
>     render text: Yajl::Encoder.encode(my_hash)
>
> Using `Yajl::Encoder.encode`(or `MultiJson.encode`for that matter)
> yields another kind of result: 12614ms (8253.6ms always spent on the
> database query)
>
> Is there something we can do about this?

Skimming through the code in encoding.rb (in active support) it looks
like the to_json method rails adds ignores ActiveSupport::JSON.backend
and just does the encoding itself. I can only imagine this is because
for most people the bottleneck is parsing rather than generation.

Fred
>
> Note:
> some may point out to try few gems like `rabl`or `acts_as_api`, but
> don't forget they are mainly for presentation purpose and they are
> comparable to the `to_json` performance in this regard.
>
> Thanks for reading.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-core?hl=en.

Reply via email to