-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
introduce benchmarks of HashSet operations
- 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; |