Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
Feature Requests
FAQ
Register
Log In
Run results for:
reduce vs while
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36 Edg/130.0.0.0
Browser:
Chrome 130
Operating system:
Linux
Device Platform:
Desktop
Date tested:
one year ago
Benchmark engine:
Benchmark.js
Reduce
145K/s
while
140K/s
View exact numbers
Test name
Executions per second
✓
Reduce
144,840 Ops/sec
while
139,828 Ops/sec
Tests:
Reduce
const charOccurances = str => str .split("") .reduce((p, c) => ({ ...p, [c]: (p[c] || 0) + 1 }), {}); console.log(charOccurances('abac'));
while
const charOccurances = (str = "") => { const response = {}; while(str.length !== 0) { const char = str.charAt(); const reg = new RegExp(char, "g"); response[char] = str.match(reg).length; str = str.replace(reg, ""); } return response } console.log(charOccurances('abac'));