On 7/25/06, Danny Kodicek <[EMAIL PROTECTED]> wrote:
Just out of interest, I tried a speed test using the three methods - mine was the fastest by a very long way:
Thanks -- I was hoping somebody would test it :)
This seemed a weird result, so I took a look for other differences. It turns out that the test for array.__proto__ == Array.prototype is *way* slower than using instanceof Array. When I replaced the two relevant lines in the other two functions, mine was relegated to a rightful third place
I thought about that when I saw yours. It kinda makes sense that it's faster when being handled internally (saves two getProperty's after all), but I would have never expected it to have such a huge effect. So we learn that instanceOf is very fast.
iterative 2387 length: 264356 recursive 1175 length: 264356 Mark's version 1096 length: 264356
This seems to be extreme. Any chance something is going wrong with the test? Did you wait a few frames before doing the first test to ensure initialization has finished? Maybe switch the order to see if the first one always is the slowest? Frankly, I only had a quick look at yours, but it seemed to follow roughly the same principle as mine. So where is the bottleneck (if the test works correctly)? BTW, the reason I didn't have a detailed look were the shortened, non-descriptive variable names. This is most likely not necessary. It makes sense for properties, but variables usually are stored as registers (if the compiler chooses to use function2 instead of the old function tag, which it normally does for class methods), the names you give them in your source code are irrelevant and don't appear in the SWF. Given the minuscule performance difference, I'd go with the original (recursive) version for elegance and readability. Unless somebody feels like giving mine a work over with flasm, that is, it has more potential for bytecode optimizations because the recursive one's bottleneck is the function call, and that can't be changed. Mark _______________________________________________ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com