Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
JSON.parse vs String.substring vs String.match for fetching one value
is it faster to get one value by JSON.parse() or directly via String.substring
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:137.0) Gecko/20100101 Firefox/137.0
Browser:
Firefox 137
Operating system:
Ubuntu
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
JSON.parse()
1504048.4 Ops/sec
String.substring
360127744.0 Ops/sec
String.match
19311402.0 Ops/sec
Script Preparation code:
var ob = `{"aenderungen":[],"_id":"64c0fc4abd2c8bd76c9553f2","name":"Maxis","geburtsdatum":"2023-08-02T00:00:00.000Z","ICD10Code":"k k k k k ","position":0,"empfangsdatum":"2023-07-26T10:58:18.716Z","hinzugefügtVon":"6498bf3b2afb897aa26d18e6","infos":{"berichte":"ggg","puls":"hallo yazn "},"positionarr":[0,0],"stationen":[],"__v":0}`
Tests:
JSON.parse()
var value = JSON.parse(ob)._id;
String.substring
const value = ob.substring(25,49);
String.match
const value = ob.match(/"_id":"(\w+)"/)[1]