-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement generic search sorted using scalar_at (#167)
- Loading branch information
1 parent
4fbea5f
commit 497263f
Showing
6 changed files
with
145 additions
and
49 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
use criterion::{black_box, criterion_group, criterion_main, Criterion}; | ||
use rand::distributions::Uniform; | ||
use rand::{thread_rng, Rng}; | ||
|
||
use vortex::compute::search_sorted::{SearchSorted, SearchSortedSide}; | ||
|
||
fn search_sorted(c: &mut Criterion) { | ||
let mut group = c.benchmark_group("search_sorted"); | ||
|
||
let mut rng = thread_rng(); | ||
let range = Uniform::new(0, 100_000_000); | ||
let mut data: Vec<i32> = (0..10_000_000).map(|_| rng.sample(range)).collect(); | ||
data.sort(); | ||
let needle = rng.sample(range); | ||
|
||
group.bench_function("std", |b| b.iter(|| black_box(data.binary_search(&needle)))); | ||
|
||
group.bench_function("vortex", |b| { | ||
b.iter(|| black_box(data.search_sorted(&needle, SearchSortedSide::Left))) | ||
}); | ||
} | ||
|
||
criterion_group!(benches, search_sorted); | ||
criterion_main!(benches); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters