2010/12/31 Salohcin <[email protected]>:
> I'm not sure there is any measurable benefit so to speak. Someone with
> more knowledge on the subject can correct me if i'm wrong.

In my particular case, some weeks ago I was able to speed-up a
function by about 30% using variable caching (i.e. "var cachedProp =
obj.property;" )

I saved every object-property (only if used twice at least) in a local
variable. I don't have access to the code (and the final results)
anymore, but It had two loops inside (about 100 iterations each one),
the function was about iterating arrays and/or objects (nothing
related with DOM access nor XHR requests). After caching about 15
properties, total time went down from 5ms to 3,4ms (measured in FF 3.6
with Firebug profiling tool). So in my case, variable-caching was a
powerful technique and now I use it in every function that needs a
good performance.

Other performance optimization techniques I used were: check
everything to avoid unnecessary loops or property access and never
compute the same thing twice. Probably you should rebuild your code
and kill readability with this two too. After a lot of tweaks the
function now runs in 0,2ms, which is a huge improvement. If you really
need a fast function, every single performance-hack is important.

I guess that you need to ask your self: should I kill readability to
get a XX% speed improvement? If I make this function XX% faster...
will it have a measurable impact in the overall execution time? And
always check that your DOM access, XHR requests or any other very slow
operations has been as optimized as possible before hacking to this
level.

--
S.Cinos
JavaScript Developer at Tuenti.com

-- 
To view archived discussions from the original JSMentors Mailman list: 
http://www.mail-archive.com/[email protected]/

To search via a non-Google archive, visit here: 
http://www.mail-archive.com/[email protected]/

To unsubscribe from this group, send email to
[email protected]

Reply via email to