mdub/representative_view — Issue #6: Representative view performance
Author: uglyog
Created: 2011-10-17 23:35:51+00:00
State: open

After profiling our rails app, Representative has been flagged as a performance bottleneck. Converting a Representative view into a Hash and calling render :json => hash.to_json decreases response time by approx 30-40% with the same JSON output.

From what I can tell, a lot of CPU time is being spent between Representative::Json#list_of and Representative::Base#resolve_value

Also, providing explicit values seems to increase performance a fair amount, i.e., converting

r.list_of :books, @books do |book|
r.element :title, book.title
r.list_of :authors, book.authors
end

to

r.list_of :books, @books do
r.element :title
r.list_of :authors
end

results in Representative::Base#representing consuming 11% of the CPU time for a response with our application.