Skip to content

Commit fd1f956

Browse files
committed
Add new benchmarks to README
1 parent c58bfa8 commit fd1f956

File tree

1 file changed

+14
-18
lines changed

1 file changed

+14
-18
lines changed

README.md

+14-18
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22

33
![Microdiff Logo](https://raw.githubusercontent.com/AsyncBanana/microdiff/master/Logo.svg)
44

5-
Microdiff is a tiny (currently <1kb), fast, zero dependency object and array comparison library. It is significantly faster than most other deep comparison libraries, and has full TypeScript support.
6-
5+
Microdiff is a tiny (<1kb), fast, zero dependency object and array comparison library. It is significantly faster than most other deep comparison libraries, and has full TypeScript support.
76

87
> 💡 I recommend reading this blog post:
98
>
@@ -17,7 +16,7 @@ Microdiff is a tiny (currently <1kb), fast, zero dependency object and array com
1716

1817
- 🚀 More than double the speed of other object diff libraries
1918
- 📦 Extremely lightweight, <1kb minified
20-
- 🌎 Supports Deno, Node, the web, and even service workers. Also comes with built-in Typescript types
19+
- 🌎 Supports Deno, Node, Bun, the web, and even service workers. Also comes with built-in Typescript types
2120
- 🔰 Very easy to use, having just a single `diff()` function
2221
- 📅 Full support for objects like `new Date()` and `new RegExp()`
2322

@@ -71,26 +70,23 @@ diff(obj1, obj2, { cyclesFix: false });
7170
# Benchmarks
7271

7372
```
74-
Benchmarks: Small object
75-
deep-diff: 17929ns - 409% slower
76-
deep-object-diff: 10763ns - 206% slower
77-
jsdiff: 79700ns - 2164% slower
78-
microdiff: 3520ns - Fastest
79-
80-
Benchmarks: Large Object
81-
deep-diff: 272887ns - 259% slower
82-
deep-object-diff: 160019ns - 111% slower
83-
jsdiff: 1688294ns - 2123% slower
84-
microdiff: 75934ns - Fastest
73+
Geometric mean of time per operation relative to Microdiff (no cycles) (100%==equal time, lower is better)
74+
microdiff (no cycles): 100%
75+
microdiff: 149%
76+
deep-diff: 197%
77+
deep-object-diff: 288%
78+
jsDiff: 1565%
8579
```
8680

87-
These benchmarks are currently only for one small object and a very large object, so they might not be accurate. I will be working on creating benchmarks with more varying types.
81+
These results are from a suite of benchmarks matching real world use cases of multiple open-source repos using various diffing algorithm, running under Node 22.12.0 on a Ryzen 7950x clocked at ~4.30 GHz. The benchmarks are run through [mitata](https://github.com/evanwashere/mitata) to minimize random variation and time most accurately. You can view the full benchmark code in [bench.js](https://github.com/AsyncBanana/microdiff/blob/master/bench.js) and the benchmarks themselves at [benchmarks/applied](https://github.com/AsyncBanana/microdiff/tree/master/benchmarks/applied).
82+
83+
Of course, [these benchmarks should be taken with a grain of salt](https://byteofdev.com/posts/javascript-benchmarking-mess/) due to the inherent errors present in benchmarking JavaScript, but if you want to run them on your own computer in your own runtime/setup, run `bench.js`.
8884

8985
# Contributing
90-
91-
Thanks for helping the project out! Contributing is pretty simple. Fork the repository (if you need more information on how to do this, check out [this GitHub guide](https://docs.github.com/en/get-started/quickstart/contributing-to-projects)), clone it to your computer, and start programming! To compile the program, run `npm run build` (replace `npm` with `pnpm` or `yarn` if you are using one of those). This will create CommonJS and ESM modules in `/dist`.
9286

93-
To benchmark microdiff, you can run `npm run bench`. This will automatically build Microdiff and run a benchmarking program comparing microdiff to other common diffing libraries.
87+
Thanks for helping the project out! Contributing is pretty simple. Fork the repository (if you need more information on how to do this, check out [this GitHub guide](https://docs.github.com/en/get-started/quickstart/contributing-to-projects)), clone it to your computer, and start programming! To compile the program, run `npm run build` (replace `npm` with `pnpm` or `yarn` if you are using one of those). This will create CommonJS and ESM modules in `/dist`.
88+
89+
To benchmark microdiff, you can run `npm run bench`. This will automatically build Microdiff and run a benchmarking program comparing microdiff to other common diffing libraries.
9490

9591
Finally, Microdiff has an extensive test suite which you should take advantage of. To make sure everything is working correctly, you can run `npm run test`. `npm run test` builds the project and then runs the entire test suite on the new version. If you are fixing a bug, be sure to add a test for that.
9692
Also, make sure you read the [Code of Conduct](https://github.com/AsyncBanana/microdiff/blob/master/CODE_OF_CONDUCT.md) before contributing.

0 commit comments

Comments
 (0)