make criterion args work, small simplification
This commit is contained in:
parent
dc2afae991
commit
c886b72dab
@ -23,6 +23,10 @@ rand = "*"
|
||||
rand_xorshift = "*"
|
||||
lazy_static = "*"
|
||||
|
||||
[lib]
|
||||
# so that criterion arguments work, see: https://bheisler.github.io/criterion.rs/book/faq.html#cargo-bench-gives-unrecognized-option-errors-for-valid-command-line-options
|
||||
bench = false
|
||||
|
||||
[[bench]]
|
||||
name = "translate_offset_with_edit_benchmark"
|
||||
harness = false
|
@ -65,21 +65,20 @@ lazy_static! {
|
||||
}
|
||||
|
||||
fn compare_translates(c: &mut Criterion) {
|
||||
let f1 = Fun::new("translate_after_edit", |b, _| {
|
||||
b.iter(|| {
|
||||
let d = &*DATA;
|
||||
line_index_utils::translate_after_edit(&d.text, d.offset, d.edits.clone());
|
||||
})
|
||||
});
|
||||
|
||||
let f2 = Fun::new("translate_offset_with_edit", |b, _| {
|
||||
b.iter(|| {
|
||||
let d = &*DATA;
|
||||
line_index_utils::translate_offset_with_edit(&d.line_index, d.offset, &d.edits);
|
||||
})
|
||||
});
|
||||
|
||||
let functions = vec![f1, f2];
|
||||
let functions = vec![
|
||||
Fun::new("translate_after_edit", |b, _| {
|
||||
b.iter(|| {
|
||||
let d = &*DATA;
|
||||
line_index_utils::translate_after_edit(&d.text, d.offset, d.edits.clone());
|
||||
})
|
||||
}),
|
||||
Fun::new("translate_offset_with_edit", |b, _| {
|
||||
b.iter(|| {
|
||||
let d = &*DATA;
|
||||
line_index_utils::translate_offset_with_edit(&d.line_index, d.offset, &d.edits);
|
||||
})
|
||||
}),
|
||||
];
|
||||
|
||||
c.bench_functions("translate", functions, ());
|
||||
}
|
||||
|
@ -270,9 +270,6 @@ pub fn translate_offset_with_edit(
|
||||
Step::Newline(n) => {
|
||||
if offset < *n {
|
||||
return res.to_line_col(offset);
|
||||
} else if offset == *n {
|
||||
res.add_line(*n);
|
||||
return res.to_line_col(offset);
|
||||
} else {
|
||||
res.add_line(*n);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user