forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
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#58644 - Centril:rollup, r=Centril
Rollup of 17 pull requests Successful merges: - rust-lang#57656 (Deprecate the unstable Vec::resize_default) - rust-lang#58059 (deprecate before_exec in favor of unsafe pre_exec) - rust-lang#58064 (override `VecDeque::try_rfold`, also update iterator) - rust-lang#58198 (Suggest removing parentheses surrounding lifetimes) - rust-lang#58431 (fix overlapping references in BTree) - rust-lang#58555 (Add a note about 2018e if someone uses `try {` in 2015e) - rust-lang#58588 (remove a bit of dead code) - rust-lang#58589 (cleanup macro after 2018 transition) - rust-lang#58591 (Dedup a rustdoc diagnostic construction) - rust-lang#58600 (fix small documentation typo) - rust-lang#58601 (Search for target_triple.json only if builtin target not found) - rust-lang#58606 (Docs: put Future trait into spotlight) - rust-lang#58607 (Fixes rust-lang#58586: Make E0505 erronous example fail for the 2018 edition) - rust-lang#58615 (miri: explain why we use static alignment in ref-to-place conversion) - rust-lang#58620 (introduce benchmarks of BTreeSet.intersection) - rust-lang#58621 (Update miri links) - rust-lang#58632 (Make std feature list sorted) Failed merges: r? @ghost
- Loading branch information
Showing
29 changed files
with
542 additions
and
210 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 |
---|---|---|
@@ -1 +1,2 @@ | ||
mod map; | ||
mod set; |
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,88 @@ | ||
use std::collections::BTreeSet; | ||
|
||
use rand::{thread_rng, Rng}; | ||
use test::{black_box, Bencher}; | ||
|
||
fn random(n1: u32, n2: u32) -> [BTreeSet<usize>; 2] { | ||
let mut rng = thread_rng(); | ||
let mut set1 = BTreeSet::new(); | ||
let mut set2 = BTreeSet::new(); | ||
for _ in 0..n1 { | ||
let i = rng.gen::<usize>(); | ||
set1.insert(i); | ||
} | ||
for _ in 0..n2 { | ||
let i = rng.gen::<usize>(); | ||
set2.insert(i); | ||
} | ||
[set1, set2] | ||
} | ||
|
||
fn staggered(n1: u32, n2: u32) -> [BTreeSet<u32>; 2] { | ||
let mut even = BTreeSet::new(); | ||
let mut odd = BTreeSet::new(); | ||
for i in 0..n1 { | ||
even.insert(i * 2); | ||
} | ||
for i in 0..n2 { | ||
odd.insert(i * 2 + 1); | ||
} | ||
[even, odd] | ||
} | ||
|
||
fn neg_vs_pos(n1: u32, n2: u32) -> [BTreeSet<i32>; 2] { | ||
let mut neg = BTreeSet::new(); | ||
let mut pos = BTreeSet::new(); | ||
for i in -(n1 as i32)..=-1 { | ||
neg.insert(i); | ||
} | ||
for i in 1..=(n2 as i32) { | ||
pos.insert(i); | ||
} | ||
[neg, pos] | ||
} | ||
|
||
fn pos_vs_neg(n1: u32, n2: u32) -> [BTreeSet<i32>; 2] { | ||
let mut neg = BTreeSet::new(); | ||
let mut pos = BTreeSet::new(); | ||
for i in -(n1 as i32)..=-1 { | ||
neg.insert(i); | ||
} | ||
for i in 1..=(n2 as i32) { | ||
pos.insert(i); | ||
} | ||
[pos, neg] | ||
} | ||
|
||
macro_rules! set_intersection_bench { | ||
($name: ident, $sets: expr) => { | ||
#[bench] | ||
pub fn $name(b: &mut Bencher) { | ||
// setup | ||
let sets = $sets; | ||
|
||
// measure | ||
b.iter(|| { | ||
let x = sets[0].intersection(&sets[1]).count(); | ||
black_box(x); | ||
}) | ||
} | ||
}; | ||
} | ||
|
||
set_intersection_bench! {intersect_random_100, random(100, 100)} | ||
set_intersection_bench! {intersect_random_10k, random(10_000, 10_000)} | ||
set_intersection_bench! {intersect_random_10_vs_10k, random(10, 10_000)} | ||
set_intersection_bench! {intersect_random_10k_vs_10, random(10_000, 10)} | ||
set_intersection_bench! {intersect_staggered_100, staggered(100, 100)} | ||
set_intersection_bench! {intersect_staggered_10k, staggered(10_000, 10_000)} | ||
set_intersection_bench! {intersect_staggered_10_vs_10k, staggered(10, 10_000)} | ||
set_intersection_bench! {intersect_staggered_10k_vs_10, staggered(10_000, 10)} | ||
set_intersection_bench! {intersect_neg_vs_pos_100, neg_vs_pos(100, 100)} | ||
set_intersection_bench! {intersect_neg_vs_pos_10k, neg_vs_pos(10_000, 10_000)} | ||
set_intersection_bench! {intersect_neg_vs_pos_10_vs_10k,neg_vs_pos(10, 10_000)} | ||
set_intersection_bench! {intersect_neg_vs_pos_10k_vs_10,neg_vs_pos(10_000, 10)} | ||
set_intersection_bench! {intersect_pos_vs_neg_100, pos_vs_neg(100, 100)} | ||
set_intersection_bench! {intersect_pos_vs_neg_10k, pos_vs_neg(10_000, 10_000)} | ||
set_intersection_bench! {intersect_pos_vs_neg_10_vs_10k,pos_vs_neg(10, 10_000)} | ||
set_intersection_bench! {intersect_pos_vs_neg_10k_vs_10,pos_vs_neg(10_000, 10)} |
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
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
Oops, something went wrong.