Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Bench fast-json-patch vs microdiff
(version: 1)
Comparing performance of:
microdiff vs FAST JSON-patch
Created:
one year ago
by:
Registered User
Jump to the latest result
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);*/
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
microdiff
FAST JSON-patch
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one month ago
)
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36 Edg/146.0.0.0
Browser/OS:
Chrome 146 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
microdiff
125430.6 Ops/sec
FAST JSON-patch
719275.8 Ops/sec
Related benchmarks:
Bench different js diff methods
Bench fast-json-patch vs jsondiffpatch
Test Countries Lodash Cmparison
Bench fast-json-patch vs deep-diff
Bench fast-json-patch apply vs fast-json-patch mutate
Bench fast-json-patch vs jsondiffpatch icl. Patching
Deletion: splice vs filter vs loop
convert and lookup 10k times
convert and lookup 10k times and 10k items
Comments
Confirm delete:
Do you really want to delete benchmark?