Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
String search vs Array search vs Obj key search
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36
Browser:
Chrome 134
Operating system:
Windows
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
String search
3533392.5 Ops/sec
Array search
2677119.5 Ops/sec
Obj key search
3470839.0 Ops/sec
Script Preparation code:
function strMonth(str) { const months3 = "jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec|янв|фев|мар|апр|май|июн|июл|авг|сен|окт|ноя|дек"; return Math.floor(months3.indexOf(str.slice(0, 3).toLowerCase()) / 4) % 12 + 1 } function arrMonth(str) { const months3 = ["jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec","янв","фев","мар","апр","май","июн","июл","авг","сен","окт","ноя","дек"]; return Math.floor(months3.indexOf(str.slice(0, 3).toLowerCase()) % 12 + 1); } function objMonth(str) { const months3 = { jan:1,feb:2,mar:3,apr:4,may:5,jun:6,jul:7,aug:8,sep:9,oct:10,nov:11,dec:12,янв:1,фев:2,мар:3,апр:4,май:5,июн:6,июл:7,авг:8,сен:9,окт:10,ноя:11,дек:12 }; return months3[str.slice(0, 3).toLowerCase()]; }
Tests:
String search
strMonth("apr"); strMonth("dec"); strMonth("дек");
Array search
arrMonth("apr"); arrMonth("dec"); arrMonth("дек");
Obj key search
objMonth("apr"); objMonth("dec"); objMonth("дек");