Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
json-diff-patch vs fast-json-patch
(version: 0)
json-diff-patch vs fast-json-patch
Comparing performance of:
jsondiffpatch vs fast-json-patch
Created:
3 years ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<script src="https://cdn.jsdelivr.net/npm/fast-json-patch/dist/fast-json-patch.min.js"></script> <script type='text/javascript' src="https://cdn.jsdelivr.net/npm/jsondiffpatch/dist/jsondiffpatch.umd.min.js"></script>
Script Preparation code:
var oldObj = { "content": { "blocks": { "block-0": { "id": "block-0", "type": "p", "leafIds": [ "leaf-2" ] }, "block-1": { "id": "block-1", "type": "p", "leafIds": [ "leaf-3" ] } }, "leaves": { "leaf-2": { "id": "leaf-2", "text": "12345" }, "leaf-3": { "id": "leaf-3", "text": "abcde" }, "leaf-4": { "id": "leaf-3", "text": "abcde" } }, "blockIds": [ "block-0", "block-1" ] }, "selection": { "isReversed": false, "isCollapsed": true, "startEl": "leaf-2", "endEl": "leaf-2", "startOffset": 12, "endOffset": 12 } } var newObj = { "content": { "blocks": { "block-0": { "id": "block-0", "type": "p", "leafIds": [ "leaf-2" ] }, "block-1": { "id": "block-1", "type": "p", "leafIds": [ "leaf-3" ] } }, "leaves": { "leaf-2": { "id": "leaf-2", "text": "12345hooba12" }, "leaf-3": { "id": "leaf-3", "text": "abcde" } }, "blockIds": [ "block-0", "block-1" ] }, "selection": { "isReversed": false, "isCollapsed": true, "startEl": "leaf-2", "endEl": "leaf-2", "startOffset": 12, "endOffset": 12 } } var diffs = []
Tests:
jsondiffpatch
var diff = jsondiffpatch.diff(oldObj, newObj) diffs.push(diff) var objnew = JSON.parse(JSON.stringify(oldObj)) jsondiffpatch.patch(oldObj, diff)
fast-json-patch
var diff = jsonpatch.compare(oldObj, newObj); diffs.push(diff) var objnew = JSON.parse(JSON.stringify(oldObj)) jsonpatch.applyPatch(oldObj, diff)
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
jsondiffpatch
fast-json-patch
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
8 months ago
)
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/139.0.0.0 Safari/537.36
Browser/OS:
Chrome 139 on Mac OS X 10.15.7
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
jsondiffpatch
185833.8 Ops/sec
fast-json-patch
420569.2 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
**Overview of the Benchmark** This benchmark compares two JavaScript libraries for diffing and patching JSON data: `jsondiffpatch` and `fast-json-patch`. The test case involves creating two identical JSON objects, making some changes to one object, and then comparing the differences between the two objects using each library. The results are used to measure the performance of each library. **Options Compared** The benchmark compares the following options: 1. **jsondiffpatch**: A library specifically designed for diffing and patching JSON data. 2. **fast-json-patch**: A lightweight, fast, and flexible library for patching JSON data, which also supports diffing. **Pros and Cons of Each Approach** **jsondiffpatch**: Pros: * Specifically designed for diffing and patching JSON data, making it a good choice for this use case. * Optimized for performance, with features like caching and memoization. Cons: * May be overkill for simple use cases, as it provides more features than needed. * Requires more code to achieve the same results as fast-json-patch. **fast-json-patch**: Pros: * Lightweight and easy to use, making it a good choice for projects where size and complexity are concerns. * Fast performance, with support for async operations. Cons: * May not be specifically designed for diffing and patching JSON data, which could impact performance in this use case. * Less features compared to jsondiffpatch, but still provides the basic functionality needed. **Other Considerations** When choosing between these libraries, consider the following factors: * Performance: If speed is critical, fast-json-patch might be a better choice. However, if you prioritize accuracy and ease of use, jsondiffpatch might be a better fit. * Complexity: If your project requires more advanced features or customization, jsondiffpatch might be a better choice. **Library Used in the Test Case** In this benchmark, both libraries are used to compare the differences between two JSON objects. The `jsondiffpatch` library is used to compute the diff and patch, while `fast-json-patch` is used to apply the patch. * **jsondiffpatch**: This library provides a higher-level abstraction for diffing and patching JSON data. It uses a more complex algorithm to compute the diff and patch, which might result in better accuracy but slower performance. * **fast-json-patch**: This library provides a lower-level interface for patching JSON data. It allows for more fine-grained control over the patching process, but also requires more code to achieve the same results as jsondiffpatch. **Special JS Features or Syntax** Neither of the libraries uses any special JavaScript features or syntax that would require additional explanation. Both libraries use standard JavaScript functions and APIs to perform their operations.
Related benchmarks:
Test Immutable ToJS vs single get
js-diff vs deep-diff - Diff creation
deep-diff vs json-fast-patch
Lodash cloneDeep vs JSON Clone (large payload)
Comments
Confirm delete:
Do you really want to delete benchmark?