forked from rust-lang/rust
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of rust-lang#66393 - ssomers:hash_benches, r=dtolnay
introduce benchmarks of HashSet operations To avoid goofs such as corrected by rust-lang#66280, I added benchmarks of binary HashSet operations. Due to the fact x.py keeps recompiling the whole shebang (or at least a big part of it) whenever you touch the test code, and because piling up all tests in one file does not strike me as future proof, I tried moving the hash benches to the separate place they are for liballoc/collections/btree. But it turns out that, in a cleaned checkout, x.py still recompiles the whole shebang whenever you touch the test code (PS or when you add or delete any irrelevant file). So I'm not going to add more tests, and I doubt others will, and these tests have proven their point already, so this PR is kind of pointless
- Loading branch information
Showing
6 changed files
with
52 additions
and
21 deletions.
There are no files selected for viewing
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,2 @@ | ||
mod map; | ||
mod set_ops; |
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,42 @@ | ||
use std::collections::HashSet; | ||
use test::Bencher; | ||
|
||
#[bench] | ||
fn set_difference(b: &mut Bencher) { | ||
let small: HashSet<_> = (0..10).collect(); | ||
let large: HashSet<_> = (0..100).collect(); | ||
|
||
b.iter(|| small.difference(&large).count()); | ||
} | ||
|
||
#[bench] | ||
fn set_is_subset(b: &mut Bencher) { | ||
let small: HashSet<_> = (0..10).collect(); | ||
let large: HashSet<_> = (0..100).collect(); | ||
|
||
b.iter(|| small.is_subset(&large)); | ||
} | ||
|
||
#[bench] | ||
fn set_intersection(b: &mut Bencher) { | ||
let small: HashSet<_> = (0..10).collect(); | ||
let large: HashSet<_> = (0..100).collect(); | ||
|
||
b.iter(|| small.intersection(&large).count()); | ||
} | ||
|
||
#[bench] | ||
fn set_symmetric_difference(b: &mut Bencher) { | ||
let small: HashSet<_> = (0..10).collect(); | ||
let large: HashSet<_> = (0..100).collect(); | ||
|
||
b.iter(|| small.symmetric_difference(&large).count()); | ||
} | ||
|
||
#[bench] | ||
fn set_union(b: &mut Bencher) { | ||
let small: HashSet<_> = (0..10).collect(); | ||
let large: HashSet<_> = (0..100).collect(); | ||
|
||
b.iter(|| small.union(&large).count()); | ||
} |
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,5 @@ | ||
#![feature(test)] | ||
|
||
extern crate test; | ||
|
||
mod hash; |
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 |
---|---|---|
@@ -1,5 +1,4 @@ | ||
//! Unordered containers, implemented as hash-tables | ||
mod bench; | ||
pub mod map; | ||
pub mod set; |