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 6.1; Win64; x64; rv:109.0) Gecko/20100101 Firefox/115.0
Browser:
Firefox 115
Operating system:
Windows 7
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
JSON
42861.0 Ops/sec
Regex
366852.6 Ops/sec
String search
691895.4 Ops/sec
indexOf
829398.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); }