Skip to content

Commit 640e091

Browse files
committed
Updated README.md with benchmark results and config parameters explanation
1 parent f0c0cdf commit 640e091

File tree

1 file changed

+39
-4
lines changed

1 file changed

+39
-4
lines changed

README.md

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ This project aims to compare their performance and functionality.
99

1010
The following PHP JSON Patch libraries are included in the benchmark:
1111

12-
1. [**blancks/fast-jsonpatch-php**](https://github.com/blancks/fast-jsonpatch-php) (v1.1.3)
12+
1. [**blancks/fast-jsonpatch-php**](https://github.com/blancks/fast-jsonpatch-php) (v1.2.3)
1313
2. [**mikemccabe/json-patch-php**](https://github.com/mikemccabe/json-patch-php) (dev-master)
1414
3. [**php-jsonpatch/php-jsonpatch**](https://github.com/raphaelstolt/php-jsonpatch) (v4.1.0)
1515
4. [**xp-forge/json-patch**](https://github.com/xp-forge/json-patch) (v2.1.0)
@@ -40,21 +40,35 @@ The benchmarks were executed on the following system:
4040

4141
## RFC 6902 Compliance Test Results
4242

43+
The compliance test strictly checks if the output json of each library is consistent with the RFC and if the library performs atomic operations. \
44+
Many libraries implicitly converts objects into arrays and while this make the compliace test fail it is still fine if you just have to consume the document in PHP.
45+
4346
| Library | Tests |
4447
|-----------------------------|---------------------------------------------------------------|
4548
| blancks/fast-jsonpatch-php | ![#008000](https://placehold.co/15x15/008000/008000.png) PASS |
4649
| mikemccabe/json-patch-php | ![#990000](https://placehold.co/15x15/990000/990000.png) FAIL |
4750
| php-jsonpatch/php-jsonpatch | ![#990000](https://placehold.co/15x15/990000/990000.png) FAIL |
4851
| xp-forge/json-patch | ![#990000](https://placehold.co/15x15/990000/990000.png) FAIL |
4952
| gamringer/php-json-patch | ![#990000](https://placehold.co/15x15/990000/990000.png) FAIL |
50-
| swaggest/json-diff | ![#008000](https://placehold.co/15x15/008000/008000.png) PASS |
53+
| swaggest/json-diff | ![#990000](https://placehold.co/15x15/990000/990000.png) FAIL |
5154
| remorhaz/php-json-patch | ![#008000](https://placehold.co/15x15/008000/008000.png) PASS |
5255

5356
> **Note:** Libraries that fails this test will be benchmarked as well if no error occurs
5457
55-
## Benchmark Results
58+
## Benchmark Results
59+
60+
The following table shows the average time each library took to apply a patch with 1000 operations to a target document as summary of the performance. \
61+
The actual benchmark data is available [here](https://docs.google.com/spreadsheets/d/1ZTDWh1k-zzhYHqZB3JMD2WRV0bPRIWUMRbLiMJhMLHk/edit?usp=sharing).
5662

57-
...
63+
| Library | Microseconds |
64+
|-----------------------------|------------------------------------|
65+
| blancks/fast-jsonpatch-php | 2903 |
66+
| mikemccabe/json-patch-php | 3355 |
67+
| swaggest/json-diff | 3638 |
68+
| gamringer/php-json-patch | 7276 |
69+
| xp-forge/json-patch | 8534 |
70+
| php-jsonpatch/php-jsonpatch | 10970 |
71+
| remorhaz/php-json-patch | N/A (needs many hours to complete) |
5872

5973
> **Note:** These results are indicative and may vary depending on the specific use case and system environment.
6074
@@ -89,6 +103,27 @@ php jpbench blancks_fast-jsonpatch
89103
```
90104

91105

106+
## Benchmark Configuration
107+
108+
Benchmark configuration is located at `./src/config.php` \
109+
The following constants are available to customize the benchmark behavior:
110+
111+
* `THREADS` the number of concurrent processes to spawn. \
112+
_The benchmark is CPU intensive, do not put a value here higher than your processor logical cores_
113+
114+
115+
* `MAX_PATCHSIZE` the maximum number of operations for a single patch to benchmark
116+
117+
118+
* `ITERATIONS_PER_PATCH` how many times each patch size is benchmarked before moving to the next
119+
120+
121+
* `PATCH_NESTED_LEVEL` the number of tokens of the JSON pointer for each patch operation
122+
123+
124+
* `OUTPUT_FOLDER` folder where the benchmark results will be stored
125+
126+
92127
## Contributing
93128

94129
Contributions are welcome! If you know of another JSON Patch library that should be included in these benchmarks or have suggestions for improving the benchmarking process, please open an issue or submit a pull request.

0 commit comments

Comments
 (0)