<script type='text/javascript' src="https://cdn.jsdelivr.net/npm/jsondiffpatch/dist/jsondiffpatch.umd.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/deep-diff@1/dist/deep-diff.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/fast-json-patch/dist/fast-json-patch.min.js"></script>
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,
}
]
};
var diff1 = jsondiffpatch.diff(obj1, obj2);
/*var objnew = jsonpatch.deepClone(obj1);
// jsondiffpatch.unpatch(objnew, diff1);*/
var diff3 = jsonpatch.compare(obj1, obj2);
/*var objnew = jsonpatch.deepClone(obj1);
jsonpatch.applyPatch(objnew, diff3, false, true);*/
--enable-precise-memory-info
flag.
Test case name | Result |
---|---|
jsondiffpatch | |
FAST JSON-patch |
Test name | Executions per second |
---|---|
jsondiffpatch | 627194.6 Ops/sec |
FAST JSON-patch | 2147855.0 Ops/sec |
Let's dive into the world of JSON patching benchmarks.
What is being tested?
The provided benchmark measures the performance difference between two libraries: fast-json-patch
and jsondiffpatch
. Specifically, it tests how quickly each library can compute the differences between two objects (obj1
and obj2
) using a JSON patching approach.
Options compared:
There are two options being compared:
Pros and Cons:
Fast-JSON-Patch:
Pros:
Cons:
jsondiffpatch:
Pros:
Cons:
Library descriptions:
Special JavaScript features:
None mentioned in this benchmark definition.
Other considerations:
fast-json-patch
and jsondiffpatch
libraries separately. In real-world scenarios, integrating these libraries with other libraries or frameworks might require additional considerations.Alternatives:
Other popular JavaScript libraries for JSON patching include:
When choosing a library, consider factors like performance, feature set, and ease of use to determine which one best fits your project's needs.