Skip to content

Commit

Permalink
Update books.json
Browse files Browse the repository at this point in the history
Signed-off-by: andylokandy <[email protected]>
  • Loading branch information
andylokandy committed Feb 25, 2020
1 parent 3b44b21 commit 9594546
Show file tree
Hide file tree
Showing 4 changed files with 542 additions and 1,015 deletions.
14 changes: 6 additions & 8 deletions benches/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,20 @@ fn load_content() -> json::JsonValue {
}

fn bench_engine(c: &mut Criterion) {
c.bench_function("add 100", |bencher| {
c.bench_function("add books", |bencher| {
let j = load_content();

let mut books: Vec<(&str, &str)> = Vec::new();

for book in j.members() {
let title = book["title"].as_str().unwrap();
books.push((title, title));
for title in j.members() {
books.push((title.as_str().unwrap(), title.as_str().unwrap()));
}

bencher.iter_batched_ref(
|| SimSearch::new(),
|engine| {
for (title, terms) in &books {
engine.insert(title, terms);
engine.insert(*title, *terms);
}
},
BatchSize::SmallInput,
Expand All @@ -39,9 +38,8 @@ fn bench_engine(c: &mut Criterion) {
let mut engine = SimSearch::new();
let j = load_content();

for book in j.members() {
let title = book["title"].as_str().unwrap();
engine.insert(title, title);
for title in j.members() {
engine.insert(title.as_str().unwrap(), title.as_str().unwrap());
}

bencher.iter(|| engine.search("odl sea"));
Expand Down
Loading

0 comments on commit 9594546

Please sign in to comment.