deque icon indicating copy to clipboard operation
deque copied to clipboard

Native array is faster than this[]

Open yzarubin opened this issue 8 years ago • 5 comments

I'm getting significantly faster performance using a native array this.arr = []; and replacing all instances of this[] with this.arr[] . Running the two_million benchmark, I'm getting ~23 milllion ops/s with this[] vs 25-26 million ops/s using this.arr[]

Thoughts?

Darwin 13.4.0 x64 Node.JS 4.1.2 V8 4.5.103.35 Intel(R) Core(TM) i7-4870HQ CPU @ 2.50GHz × 8

yzarubin avatar Jan 14 '16 03:01 yzarubin

@yzarubin there's this and quite a few other things that can be done for perf on deque.

But, with the lack of maintenance on this repo I ended up rolling my own double-ended queue which well out performs this. 🙈

image

Salakar avatar Jul 02 '16 05:07 Salakar

PRs welcome of course :) it has been 2-3 years so it's expected some things have been changed in v8 :P

petkaantonov avatar Jul 02 '16 18:07 petkaantonov

@petkaantonov I considered PR'ing this, but I didn't know where to start as it was different implementation and was concerned the PR would sit there and go mouldy 😄

Was helpful though seeing how you initially approached things, always looking through your source code like the stalker that I am. 🌝

Salakar avatar Jul 02 '16 18:07 Salakar

@Salakar you should submit a PR so all the dependents can benefit :)

calebboyd avatar Nov 20 '16 04:11 calebboyd

@calebboyd I didn't want to be 'that guy' =]

You're more than welcome to do one however

Salakar avatar Nov 21 '16 09:11 Salakar