my fork of dmp
Updated benches
Anubhab Bandyopadhyay 2024-08-28
parent 369bf55 · commit 3eb9c8a
-rw-r--r--README.md29
1 files changed, 16 insertions, 13 deletions
diff --git a/README.md b/README.md
index 45fb2c1..5f4aad3 100644
--- a/README.md
+++ b/README.md
@@ -3,13 +3,9 @@
This library is a port of the [Diff Match Patch](https://github.com/dmsnell/diff-match-patch) to Rust. The
diff implementation is based on [Myers' diff algorithm](https://neil.fraser.name/writing/diff/myers.pdf).
-# NOT FOR PRODUCTION (YET!)
-
-Please note, this experiment has a fundamental flaw! Working with `&[u8]` if the source and destination libraries both work with `rust` or can represent `String` as `Uint8Array`. Which means, because we are working with `&[u8]` we are losing interoperatibility between libraries or other implementations of DiffMatchPatch.
-
## What's different in this implementation?
-- Instead of `String` or `Vec<Char>` this library works with `&[u8]` avoiding allocation as much as possible, this in-turn provides significant performance boost [See Benchmarks](#benchmarks)
+- Instead of `String` this library works with `&[u8]` avoiding allocation as much as possible, this in-turn provides significant performance boost [See Benchmarks](#benchmarks)
- The **line diff** speedup follows a slightly more efficient execution path
## Benchmarks
@@ -18,20 +14,27 @@ Benchmarks are maintained [diff-match-patch-bench repository](https://github.com
# diff-match-patch-rs-bench
Benchmarking the crate `diff-match-patch-rs` against other implementations.
-## `Diff`
-| Lang. | Library | Avg. (ms) | High (ms) | Low (ms) | Bencher | Mode |
-|:-------:|:---------:|:-----------:|:-----------:|:----------:|:---------:|:-----:
-| `rust` | [diff_match_patch v0.1.1](https://crates.io/crates/diff_match_patch) | 68.108 | 68.178 | 68.062 | Criterion | - |
-| `rust` | [diffmatchpatch v0.0.4](https://crates.io/crates/diffmatchpatch) | 66.454 | 66.476 | 66.434 | Criterion | - |
-| `rust` | [dmp v0.2.0](https://crates.io/crates/dmp) | 69.019 | 66.476 | 68.991 | Criterion | - |
-| `rust` | [diff-match-patch-rs](https://github.com/AnubhabB/diff-match-patch-rs.git)<sup>our</sup> | 65.487 | 65.519 | 65.458 | Criterion | `Efficient` |
-| `rust` | [diff-match-patch-rs](https://github.com/AnubhabB/diff-match-patch-rs.git)<sup>our</sup> | 65.642 | 65.667 | 65.621 | Criterion | `Compat` |
+## Benchmark
+| Lang. | Library | Diff Avg. | Patch Avg. | Bencher | Mode | Correct |
+|:-------:|:----------------------------------------------------------------------------------------:|:---------:|:----------:|:----------:|:-----------:|:-------:|
+| `rust` | [diff_match_patch v0.1.1<sup>**</sup>](https://crates.io/crates/diff_match_patch) | 68.108 ms | 10.596 ms | Criterion | - | ✅ |
+| `rust` | [diffmatchpatch v0.0.4<sup>***</sup>](https://crates.io/crates/diffmatchpatch) | 66.454 ms | - | Criterion | - | ❌ |
+| `rust` | [dmp v0.2.0](https://crates.io/crates/dmp) | 69.019 ms | 14.654 ms | Criterion | - | ✅ |
+| `rust` | [diff-match-patch-rs](https://github.com/AnubhabB/diff-match-patch-rs.git)<sup>our</sup> | 65.487 ms | 631.13 µs | Criterion | `Efficient` | ✅ |
+| `rust` | [diff-match-patch-rs](https://github.com/AnubhabB/diff-match-patch-rs.git)<sup>our</sup> | 65.642 ms | 1.1703 ms | Criterion | `Compat` | ✅ |
+| `go` | [go-diff<sup>*</sup>](https://github.com/sergi/go-diff) | 50.31 ms | 135.2 ms | go test | - | ❌ |
+| `node` | [diff-match-patch](https://www.npmjs.com/package/diff-match-patch) | 246.90 ms | 1.07 ms | tinybench | - | ✅ |
+| `python`| [diff-match-patch](https://pypi.org/project/diff-match-patch/) | 1.01 s | 0.25 ms | timeit | - | ✅ |
>
> Note:
> Omitting [dissimilar](https://crates.io/crates/dissimilar) from the results, I believe that crate has different goals and a headon benchmark is not fair
> Results: Avg[197.30] High[197.46] Low[197.19]
+>
+> `*` [go-diff](https://github.com/sergi/go-diff) seems to generate wrong diffs for emoticons. This benchmark is on the text with the emoticons removed. <br>
+> `**` Adds an extra clone to the iterator because the `patch_apply` method takes mutable refc. to `diffs` <br>
+> `***` The crate [diffmatchpatch v0.0.4](https://crates.io/crates/diffmatchpatch) is still a WIP, cound't find the `patch_apply` method <br>
## Related projects