remove slower impl, add benchmarks

This commit is contained in:
Bernardo 2018-12-21 18:51:31 +01:00
parent a005d2a614
commit d6312085a1
6 changed files with 304 additions and 201 deletions

View file

@ -24,6 +24,10 @@ pub fn arb_offset(text: &str) -> BoxedStrategy<TextUnit> {
}
pub fn arb_edits(text: &str) -> BoxedStrategy<Vec<AtomTextEdit>> {
arb_edits_custom(&text, 0, 7)
}
pub fn arb_edits_custom(text: &str, min: usize, max: usize) -> BoxedStrategy<Vec<AtomTextEdit>> {
if text.is_empty() {
// only valid edits
return Just(vec![])
@ -37,9 +41,10 @@ pub fn arb_edits(text: &str) -> BoxedStrategy<Vec<AtomTextEdit>> {
}
let offsets = text_offsets(text);
let max_cuts = offsets.len().min(7);
let max_cuts = max.min(offsets.len());
let min_cuts = min.min(offsets.len() - 1);
proptest::sample::subsequence(offsets, 0..max_cuts)
proptest::sample::subsequence(offsets, min_cuts..max_cuts)
.prop_flat_map(|cuts| {
let strategies: Vec<_> = cuts
.chunks(2)