2009/7/20 John Resig <jere...@gmail.com>:
> You need to be careful with your testing. Executing a function which has the
> regexp will result in non-deterministic results (the function call itself
> will probably take longer to run than the actual regexp being executed).
>
> A revised test:
> http://dev.jquery.com/~john/test/regexp.html
>
> Results (New vs. Old):
> FF 3.5   123ms  119ms
> SF 4.0      8ms     11ms
> IE 6.0    220ms  490ms
>

Running that test repeatedly (with the iterations increased to
6,000,000 for Chrome 2 and 600,000 for FF3.5 and IE6) showed no real
difference on Chrome and FF: sometimes a() is slightly faster,
sometimes b() is slightly faster, sometimes they're identical.

However IE6 consistently runs a() in almost half the time taken by
b(), so this optimisation seems to be worthwhile for at least one
browser (or one version thereof), and to cause no noticeable
deterioration in others. (I'm on a client site, so I don't have access
to any other IE versions to test at the moment.)

However I'd be interested to see what happens to the non-IE6 browsers
when the variable is some way up the scope chain from the invocation.
Unfortunately my client expects me to actually do some work while I'm
here, so I'll have to leave that for another time ;-)

Regards,

Nick.
-- 
Nick Fitzsimons
http://www.nickfitz.co.uk/

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"jQuery Development" group.
To post to this group, send email to jquery-dev@googlegroups.com
To unsubscribe from this group, send email to 
jquery-dev+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/jquery-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to