Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>UPDATE: <a href="https://github.com/jsperf/jsperf.com/issues/18#issuecomment-113569132">Note that JSPref is currently down</a></strong></p> <p><em>(i have saved a copy of the test case, and will update the answer once JSPref is fixed / a successor is found)</em></p> <hr> <p>Hmm... maybe an overkill for the answer... but I created <a href="http://jsperf.com/object-vs-array-vs-native-linked-list">a test suite, precisely to explore these issues (and more)</a> (<a href="http://web.archive.org/web/20150907055636/http://jsperf.com/object-vs-array-vs-native-linked-list">archived copy</a>).</p> <p>And in that sense, you can see the performance issues in this 50+ test case tester (it will take a long time).</p> <p>Also as its name suggest, it explores the usage of using the native linked list nature of the DOM structure.</p> <p><a href="http://pic-o.com/blog/2011/12/divlinkedlist/">(Currently down, rebuilt in progress) More details on my blog regarding this</a>.</p> <p><strong>The summary is as followed</strong></p> <ul> <li>V8 Array is Fast, VERY FAST </li> <li>Array push / pop / shift is ~approx 20x+ faster than any object equivalent.</li> <li>Surprisingly <code>Array.shift()</code> is fast ~approx 6x slower than an array pop, but is ~approx 100x faster than an object attribute deletion.</li> <li>Amusingly, <code>Array.push( data );</code> is faster than <code>Array[nextIndex] = data</code> by almost 20 (dynamic array) to 10 (fixed array) times over.</li> <li><code>Array.unshift(data)</code> is slower as expected, and is ~approx 5x slower than a new property adding.</li> <li>Nulling the value <code>array[index] = null</code> is faster than deleting it <code>delete array[index]</code> (undefined) in an array by ~approx 4x++ faster.</li> <li>Surprisingly Nulling a value in an object is <code>obj[attr] = null</code> ~approx 2x slower than just deleting the attribute <code>delete obj[attr]</code></li> <li>Unsurprisingly, mid array <code>Array.splice(index,0,data)</code> is slow, very slow. </li> <li>Surprisingly, <code>Array.splice(index,1,data)</code> has been optimized (no length change) and is 100x faster than just splice <code>Array.splice(index,0,data)</code></li> <li>unsurprisingly, the divLinkedList is inferior to an array on all sectors, except <code>dll.splice(index,1)</code> removal (Where it broke the test system).</li> <li><strong>BIGGEST SURPRISE</strong> of it all [as jjrv pointed out], V8 array writes are slightly faster than V8 reads =O</li> </ul> <p><strong>Note:</strong> These metrics applies only to large array/objects which v8 does not "entirely optimise out". There can be very isolated optimised performance cases for array/object size less then an arbitrary size (24?). More details can be seen extensively across several google IO videos.</p> <p><strong>Note 2:</strong> These wonderful performance results are not shared across browsers, especially <code>*cough*</code> IE. Also the test is huge, hence i yet to fully analyze and evaluate the results : please edit it in =)</p> <p><strong>Updated Note (dec 2012):</strong> Google representatives have videos on youtubes describing the inner workings of chrome itself (like when it switches from a linkedlist array to a fixed array, etc), and how to optimize them. See <a href="https://www.youtube.com/watch?feature=player_detailpage&amp;v=XAqIpGU8ZZk#t=994s">GDC 2012: From Console to Chrome</a> for more.</p> <p><strong>Updated Note (feb 2013):</strong> Thx @badunk, for providing the video link at the exact point</p> <p><strong>Updated Note (june 2016):</strong> Thx @Benedikt, regarding array push performance difference in fixed / dynamic arrays.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload