Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
JSON Parse vs regex
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Android 13; Mobile; rv:127.0) Gecko/127.0 Firefox/127.0
Browser:
Firefox Mobile 127
Operating system:
Android
Device Platform:
Mobile
Date tested:
one year ago
Test name
Executions per second
JSON
42762.1 Ops/sec
Regex
219967.0 Ops/sec
String search
182025.1 Ops/sec
indexOf
152568.9 Ops/sec
Script Preparation code:
var entries = [{ "data": "random_string_one", "comment": "{\"random_other_field_one\":\"this is a bunch of sample data\",\"random_other_field_two\":\"this is another set of sample data\",\"random_other_field_three\":\"this is another bit of sample data\",\"random_other_field_four\":\"this is another glob of sample data\",\"segregationRequirement\":2}" }, { "data": "random_string_one", "comment": "{\"random_other_field_one\":\"this is a bunch of sample data\",\"random_other_field_two\":\"this is another set of sample data\",\"random_other_field_three\":\"this is another bit of sample data\",\"random_other_field_four\":\"this is another glob of sample data\",\"segregationRequirement\":221}" }, { "data": "random_string_one", "comment": "{\"random_other_field_one\":\"this is a bunch of sample data\",\"random_other_field_two\":\"this is another set of sample data\",\"random_other_field_three\":\"this is another bit of sample data\",\"random_other_field_four\":\"this is another glob of sample data\",\"segregationRequirement\":2}" }, { "data": "random_string_one", "comment": "{\"random_other_field_one\":\"this is a bunch of sample data\",\"random_other_field_two\":\"this is another set of sample data\",\"random_other_field_three\":\"this is another bit of sample data\",\"random_other_field_four\":\"this is another glob of sample data\",\"segregationRequirement\":2}" }, { "data": "random_string_one", "comment": "{\"random_other_field_one\":\"this is a bunch of sample data\",\"random_other_field_two\":\"this is another set of sample data\",\"random_other_field_three\":\"this is another bit of sample data\",\"random_other_field_four\":\"this is another glob of sample data\",\"segregationRequirement\":221}" }, { "data": "random_string_one", "comment": "{\"random_other_field_one\":\"this is a bunch of sample data\",\"random_other_field_two\":\"this is another set of sample data\",\"random_other_field_three\":\"this is another bit of sample data\",\"random_other_field_four\":\"this is another glob of sample data\",\"segregationRequirement\":2}" }, { "data": "random_string_one", "comment": "{\"random_other_field_one\":\"this is a bunch of sample data\",\"random_other_field_two\":\"this is another set of sample data\",\"random_other_field_three\":\"this is another bit of sample data\",\"random_other_field_four\":\"this is another glob of sample data\",\"segregationRequirement\":221}" }, { "data": "random_string_one", "comment": "{\"random_other_field_one\":\"this is a bunch of sample data\",\"random_other_field_two\":\"this is another set of sample data\",\"random_other_field_three\":\"this is another bit of sample data\",\"random_other_field_four\":\"this is another glob of sample data\",\"segregationRequirement\":2}" }, { "data": "random_string_one", "comment": "{\"random_other_field_one\":\"this is a bunch of sample data\",\"random_other_field_two\":\"this is another set of sample data\",\"random_other_field_three\":\"this is another bit of sample data\",\"random_other_field_four\":\"this is another glob of sample data\",\"segregationRequirement\":221}" }, { "data": "random_string_one", "comment": "{\"random_other_field_one\":\"this is a bunch of sample data\",\"random_other_field_two\":\"this is another set of sample data\",\"random_other_field_three\":\"this is another bit of sample data\",\"random_other_field_four\":\"this is another glob of sample data\",\"segregationRequirement\":221}" }, { "data": "random_string_one", "comment": "{\"random_other_field_one\":\"this is a bunch of sample data\",\"random_other_field_two\":\"this is another set of sample data\",\"random_other_field_three\":\"this is another bit of sample data\",\"random_other_field_four\":\"this is another glob of sample data\",\"segregationRequirement\":2}" }, { "data": "random_string_one", "comment": "{\"random_other_field_one\":\"this is a bunch of sample data\",\"random_other_field_two\":\"this is another set of sample data\",\"random_other_field_three\":\"this is another bit of sample data\",\"random_other_field_four\":\"this is another glob of sample data\",\"segregationRequirement\":2}" }, { "data": "random_string_one", "comment": "{\"random_other_field_one\":\"this is a bunch of sample data\",\"random_other_field_two\":\"this is another set of sample data\",\"random_other_field_three\":\"this is another bit of sample data\",\"random_other_field_four\":\"this is another glob of sample data\",\"segregationRequirement\":2}" }, { "data": "random_string_one", "comment": "{\"random_other_field_one\":\"this is a bunch of sample data\",\"random_other_field_two\":\"this is another set of sample data\",\"random_other_field_three\":\"this is another bit of sample data\",\"random_other_field_four\":\"this is another glob of sample data\",\"segregationRequirement\":221}" }, { "data": "random_string_one", "comment": "{\"random_other_field_one\":\"this is a bunch of sample data\",\"random_other_field_two\":\"this is another set of sample data\",\"random_other_field_three\":\"this is another bit of sample data\",\"random_other_field_four\":\"this is another glob of sample data\",\"segregationRequirement\":2}" } ];
Tests:
JSON
const arr = []; for (const entry of entries) { const value = JSON.parse(entry.comment); arr.push(value.segregationRequirement); }
Regex
const arr = []; const re = /"segregationRequirement":\s*(\d+)[,}]/; for (const entry of entries) { const match = entry.comment.match(re) arr.push(match[1]); }
String search
const arr = []; for (const entry of entries) { const found = entry.comment.includes('"segregationRequirement":2'); arr.push(found); }
indexOf
const arr = []; for (const entry of entries) { const found = entry.comment.indexOf('"segregationRequirement":2') !== -1; arr.push(found); }