diff options
Diffstat (limited to 'bench/snippets/array-shift.mjs')
-rw-r--r-- | bench/snippets/array-shift.mjs | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/bench/snippets/array-shift.mjs b/bench/snippets/array-shift.mjs new file mode 100644 index 000000000..2b95bbc9d --- /dev/null +++ b/bench/snippets/array-shift.mjs @@ -0,0 +1,16 @@ +import { bench, run } from "mitata"; + +var myArray = new Array(5); +bench("[1, 2, 3, 4, 5].shift()", () => { + // we do this to prevent constant folding optimizations + if (myArray.length !== 5) myArray.length = 5; + myArray[0] = 1; + myArray[1] = 2; + myArray[2] = 3; + myArray[3] = 4; + myArray[4] = 5; + + myArray.shift(); +}); + +await run(); |