-
Notifications
You must be signed in to change notification settings - Fork 444
Description
I was doing some performance work and wondered whether Jbuilder was the culprit. After seeing some reports that Jbuilder can be quite slow I wondered whether the method_missing approach to Jbuilder was the culprit. So I changed the code to define methods whenever a key is used the first time. There usually aren't lots of keys in an app and since method_missing is not free, I thought it was a worthwhile space/time tradeoff.
In my case, it made no noticeable improvements in performance, largely because most of my performance issues were due to Rails code that was stitching model associations together while I was constructing the JSON. Presumably there would have been a noticeable gain if I had successfully removed Rails from the equation and perhaps I should write a test or two to confirm that.
However - I bring it up because the end result was that I was able to figure out what part of my JSON structure was taking unexpected amounts of time because when I profiled I could see exactly how much time was spent processing each key, since the keys all became methods. And I thought that was sort of interesting.
Is it interesting?