Labels
Date tested:
4 years ago
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.113 Safari/537.36
Test name
Executions per second
old
20.0 Ops/sec
new
24352.7 Ops/sec
Benchmark definition (click to collapse):
HTML Preparation code:
<script src='https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.7.11/lodash.min.js'></script>
Script Preparation code:
function getRandomInt(max) { return Math.floor(Math.random() * Math.floor(max)); } var values = []; for(var i = 0; i < 1000; i++){ values.push(getRandomInt(10000)); }
Tests:
old
const result = []; for (let i = _.min(values); i <= _.max(values); i++) { result.push(i); } _.reverse(result);
new
const startValue = Math.min(...values); const endValue = Math.max(...values); const result = new Array(endValue - startValue); for (let value = endValue, index = 0; value >= startValue; value--, index++) { result[index] = value; } return result;
Open this result on MeasureThat.net