aboutsummaryrefslogtreecommitdiff
path: root/bench/snippets/array-shift.mjs
blob: 2b95bbc9d077f0ab49fa5a3344e2dc1c4c08e815 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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();