Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Test string concat
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36
Browser:
Chrome 130
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
1 All together
442.4 Ops/sec
2 Separate concats
436.2 Ops/sec
HTML Preparation code:
<script src='https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.22.0/moment.min.js'></script>
Tests:
1 All together
const getDuration = () => { const duration = moment.duration(1234567, 'seconds'); const days = Math.floor(duration.asDays()); const time = `${days > 0 ? `${days}d` : ''}${duration.hours()}h${duration.minutes()}m`; return time; } for (let i = 0; i < 1000; ++i) { console.log(getDuration()); }
2 Separate concats
const getDuration = () => { const seconds = 1234567; const duration = moment.duration(seconds, 'seconds'); let time = ''; const days = Math.floor(duration.asDays()); if (days > 0) { time += days + 'd'; } time += duration.hours() +'h' + duration.minutes() + 'm'; return time; } for (let i = 0; i < 1000; ++i) { console.log(getDuration()); }