Open Pauan opened 9 years ago
First step would be to build a benchmark. If someone provides a PR for a bench, I can measure across all the SauceLabs configurations and get some data.
I am interested in simplifying ASAP based on this insight. Pull requests welcome for benchmark or simplification of the queue.
Okay, how would I (or anybody else) go about submitting a benchmark to this repository?
@Pauan I am open to nearly anything. We can refine as we go.
I have created a jsperf for queues.
drain_Array
is a naiveArray.prototype.shift
,drain_ArrayQueue
is asap's optimization, anddrain_Queue
uses an implementation of Queues that has O(1) push and amortized O(1) pull.With my machine, using Google Chrome, asap's optimization for array removal ends up being significantly slower than a naive shift! It seems likely that Chrome already optimizes shift (possibly using a similar technique that asap uses).
The Queue implementation is roughly the same speed as naive shift, but it should be consistently fast on all browsers (even those that don't optimize shift).
Of course, it is possible that I messed up in making the test, and that the results are incorrect.