Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
Feature Requests
FAQ
Register
Log In
Run results for:
Array pop-push vs last index element check
Comparing pop-push method vs last index check for an array element
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:133.0) Gecko/20100101 Firefox/133.0
Browser:
Firefox 133
Operating system:
Windows
Device Platform:
Desktop
Date tested:
one year ago
Benchmark engine:
Benchmark.js
pop-push check
45.3M/s
last-index check
6.4M/s
View exact numbers
Test name
Executions per second
✓
pop-push check
45,289,856 Ops/sec
last-index check
6,391,236 Ops/sec
Script Preparation code:
var arr1 = [0,1,2,3,4,5,6,7,8,9]; var arr2 = []; function pushPopLast(arr, n) { const element = arr.pop(); arr.push(element); return element === n; } function indexLast(arr, n) { const element = arr[arr.lenght - 1]; return element === n; }
Tests:
pop-push check
pushPopLast(arr1, 8); pushPopLast(arr1, 9); pushPopLast(arr2, 9);
last-index check
indexLast(arr1, 8); indexLast(arr1, 9); indexLast(arr2, 9);