Bob Ippolito wrote:
> Have you done any benchmarks of Queue and Stack vs. using an Array?
> I'd like to know at about what size (if any) that a Queue or Stack
> abstraction becomes faster. I can't imagine it'd make sense to use it
> for Deferred, given that chains don't get all that long...
Actually, I've just done some tests, and it looks like Queue is even
faster than array pushing and shifting even with only one element in
there. From Firebug in Firefox on Linux:
>>> q = new Queue(); t1 = new Date(); for (i = 0; i < 10000; i++) { q.put(i);
>>> q.get(); }; t2 = new Date(); t2 - t1
217
>>> a = new Array(); t1 = new Date(); for (i = 0; i < 10000; i++) { a.push(i);
>>> a.shift(); }; t2 = new Date(); t2 - t1
250
That's kind of surprising to me, but there you go. The difference only
gets more pronounced with collections of larger size.
I haven't measured Stack specifically for speed, but it's written the
same way, so I expect it performs well.
--
paul
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"MochiKit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/mochikit
-~----------~----~----~----~------~----~------~--~---