Script Preparation code:
x
 
var vertices = [
      [1, 0, 0, 0],
      [0, 1, 0, 0],
      [0, 0, 1, 0],
      [0, 0, 0, 1],
    ]
var myCopy = null;
Tests:
  • JSON.stringify

     
    myCopy = JSON.parse(JSON.stringify(vertices));
  • slice

     
    myCopy = vertices.slice();
  • Array from

     
    myCopy = Array.from(vertices)
  • Spread

     
    myCopy = [...vertices]
  • structuredClone

     
    myCopy = structuredClone(vertices)
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    JSON.stringify
    slice
    Array from
    Spread
    structuredClone

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 3 months ago)
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:134.0) Gecko/20100101 Firefox/134.0
Firefox 134 on Windows
View result in a separate tab
Test name Executions per second
JSON.stringify 723909.2 Ops/sec
slice 27469528.0 Ops/sec
Array from 10357910.0 Ops/sec
Spread 13356070.0 Ops/sec
structuredClone 366717.7 Ops/sec