From a74b41d7ed98315161d8fcb46aa33356f4d7cc8e Mon Sep 17 00:00:00 2001 From: Paul Masurel Date: Tue, 21 Feb 2017 11:43:55 +0900 Subject: [PATCH] NOBUG run benchmark over exactly 100 K elements --- src/postings/mod.rs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/postings/mod.rs b/src/postings/mod.rs index d22b0e9f5..d0ecdb9f5 100644 --- a/src/postings/mod.rs +++ b/src/postings/mod.rs @@ -229,14 +229,23 @@ mod tests { let mut rng: XorShiftRng = XorShiftRng::from_seed(*seed); let index = Index::create_in_ram(schema); + let mut count_a = 0; + let mut count_b = 0; + let posting_list_size = 100_000; { let mut index_writer = index.writer_with_num_threads(1, 40_000_000).unwrap(); - for _ in 0 .. 1_500_000 { + for _ in 0 .. { + if count_a >= posting_list_size && + count_b >= posting_list_size { + break; + } let mut doc = Document::default(); - if rng.gen_weighted_bool(15) { + if count_a < posting_list_size && rng.gen_weighted_bool(15) { + count_a += 1; doc.add_text(text_field, "a"); } - if rng.gen_weighted_bool(10) { + if count_b < posting_list_size && rng.gen_weighted_bool(10) { + count_b += 1; doc.add_text(text_field, "b"); } index_writer.add_document(doc).unwrap();