my fork of dmp
Diffstat (limited to 'benches/diff.rs')
-rw-r--r--benches/diff.rs20
1 files changed, 20 insertions, 0 deletions
diff --git a/benches/diff.rs b/benches/diff.rs
new file mode 100644
index 0000000..26d5085
--- /dev/null
+++ b/benches/diff.rs
@@ -0,0 +1,20 @@
+use std::path::Path;
+
+use criterion::{criterion_group, criterion_main, Criterion};
+use diff_match_patch_rs::dmp::DiffMatchPatch;
+
+
+fn diff_main(c: &mut Criterion) {
+ let basedir = Path::new("testdata");
+ let old = std::fs::read_to_string(basedir.join("txt_old.txt")).unwrap();
+ let new = std::fs::read_to_string(basedir.join("txt_new.txt")).unwrap();
+
+ let dmp = DiffMatchPatch::default();
+
+ c.bench_function("diff-match-patch", |bencher| {
+ bencher.iter(|| dmp.diff_main(&old, &new).unwrap());
+ });
+}
+
+criterion_group!(diff, diff_main);
+criterion_main!(diff); \ No newline at end of file