Closed dnlmlr closed 2 years ago
Merging #46 (a7fce30) into master (f400043) will not change coverage. The diff coverage is
100.00%
.:exclamation: Current head a7fce30 differs from pull request most recent head 61812bf. Consider uploading reports for the commit 61812bf to get more accurate results
@@ Coverage Diff @@
## master #46 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 1 1
Lines 224 237 +13
Branches 48 49 +1
=========================================
+ Hits 224 237 +13
Impacted Files | Coverage Δ | |
---|---|---|
index.js | 100.00% <100.00%> (ø) |
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact)
,ø = not affected
,? = missing data
Powered by Codecov. Last update f400043...61812bf. Read the comment docs.
I made some further optimizations to the
_copyArray
function that I missed last time (#43) and also optimized the_fromArray
function. This in turn provides a large improvement when initializing theDenque
from an array and also in some situations when exporting to an array.Creating the queue from an array with the new preallocating code avoids growth and is a significant improvement on large arrays:
338 ops/sec vs 841 ops/sec
Using
Array.slice
in_copyArray
to create copies with the same size on contiguous buffer data is also a pretty good performance boost in situations where it applies. This applies in every situation wherehead < tail
. Not sure why but before whenhead < tail
andhead != 0
, is was noticeably slow. This is now fixed92.41 ops/sec vs 156 ops/sec
when head is 0, but no wrapping39.84 ops/sec vs 151 ops/sec
when head is not 0, but no wrapping90.74 ops/sec vs 91.14 ops/sec
when wrappingThe full benchmark results and scripts for validation is again found in the benchmark repository
PS: The
_fromArray
optimization adds a_nextPowerOf2
function that calculates the next power of 2 to directly allocate the buffer with the correct size. This could be used to implement #42.