Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Bench fast-json-patch vs microdiff
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/133.0.0.0 Safari/537.36
Browser:
Chrome 133
Operating system:
Windows
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
microdiff
318247.4 Ops/sec
FAST JSON-patch
1635221.1 Ops/sec
HTML Preparation code:
<script src="https://cdn.jsdelivr.net/npm/fast-json-patch@3.1.1/dist/fast-json-patch.min.js"></script> <script> // Add this in your benchmark setup code function diff(t,e,r={cyclesFix:!0},s=[]){ const richTypes={Date:!0,RegExp:!0,String:!0,Number:!0}; let a=[]; const c=Array.isArray(t); for(const i in t){ const o=t[i],n=c?+i:i; if(!(i in e)){a.push({type:"REMOVE",path:[n],oldValue:t[i]});continue} const p=e[i],y="object"==typeof o&&"object"==typeof p&&Array.isArray(o)===Array.isArray(p); !(o&&p&&y)||richTypes[Object.getPrototypeOf(o)?.constructor?.name]||r.cyclesFix&&s.includes(o)?o===p||Number.isNaN(o)&&Number.isNaN(p)||y&&(isNaN(o)?o+""==p+"":+o==+p)||a.push({path:[n],type:"CHANGE",value:p,oldValue:o}):a.push.apply(a,diff(o,p,r,r.cyclesFix?s.concat([o]):[]).map((t=>(t.path.unshift(n),t)))) } const i=Array.isArray(e); for(const r in e)r in t||a.push({type:"CREATE",path:[i?+r:r],value:e[r]}); return a } // Now you can use 'diff' in your benchmark tests </script>
Script Preparation code:
obj1= { name: "Argentina", cities: [ { name: 'Buenos Aires', population: 13028000, }, { name: 'Cordoba', population: 1430023, }, { name: 'Rosario', population: 1136286, }, { name: 'Mendoza', population: 901126, }, { name: 'San Miguel de Tucuman', population: 800000, } ] }; obj2= { name: "Argentina", cities: [ { name: 'Cordoba', population: 1430023, }, { name: 'Mendoza', population: 901126, }, { name: 'San Miguel de Tucuman', population: 550000, } ] };
Tests:
microdiff
var diff1 = diff(obj1, obj2); /*var objnew = jsonpatch.deepClone(obj1); // jsondiffpatch.unpatch(objnew, diff1);*/
FAST JSON-patch
var diff3 = jsonpatch.compare(obj1, obj2); /*var objnew = jsonpatch.deepClone(obj1); jsonpatch.applyPatch(objnew, diff3, false, true);*/