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 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36
Browser:
Chrome 122
Operating system:
Windows
Device Platform:
Desktop
Date tested:
2 years ago
Test name
Executions per second
JSON
86302.5 Ops/sec
Regex
534089.1 Ops/sec
String search
561792.6 Ops/sec
indexOf
570568.1 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); }