-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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 #57627 - Centril:rollup, r=Centril
Rollup of 7 pull requests Successful merges: - #57253 (Make privacy checking, intrinsic checking and liveness checking incremental) - #57352 (forbid manually impl'ing one of an object type's marker traits) - #57537 (Small perf improvement for fmt) - #57579 (Add core::iter::once_with()) - #57587 (Add 'rustc-env:RUST_BACKTRACE=0' to const-pat-ice test) - #57608 (Simplify 'product' factorial example) - #57614 ([rustdoc] Fix crates filtering box not being filled) Failed merges: r? @ghost
- Loading branch information
Showing
27 changed files
with
534 additions
and
29 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
use std::io::{self, Write as IoWrite}; | ||
use std::fmt::{self, Write as FmtWrite}; | ||
use test::Bencher; | ||
|
||
#[bench] | ||
fn write_vec_value(bh: &mut Bencher) { | ||
bh.iter(|| { | ||
let mut mem = Vec::new(); | ||
for _ in 0..1000 { | ||
mem.write_all("abc".as_bytes()).unwrap(); | ||
} | ||
}); | ||
} | ||
|
||
#[bench] | ||
fn write_vec_ref(bh: &mut Bencher) { | ||
bh.iter(|| { | ||
let mut mem = Vec::new(); | ||
let wr = &mut mem as &mut dyn io::Write; | ||
for _ in 0..1000 { | ||
wr.write_all("abc".as_bytes()).unwrap(); | ||
} | ||
}); | ||
} | ||
|
||
#[bench] | ||
fn write_vec_macro1(bh: &mut Bencher) { | ||
bh.iter(|| { | ||
let mut mem = Vec::new(); | ||
let wr = &mut mem as &mut dyn io::Write; | ||
for _ in 0..1000 { | ||
write!(wr, "abc").unwrap(); | ||
} | ||
}); | ||
} | ||
|
||
#[bench] | ||
fn write_vec_macro2(bh: &mut Bencher) { | ||
bh.iter(|| { | ||
let mut mem = Vec::new(); | ||
let wr = &mut mem as &mut dyn io::Write; | ||
for _ in 0..1000 { | ||
write!(wr, "{}", "abc").unwrap(); | ||
} | ||
}); | ||
} | ||
|
||
#[bench] | ||
fn write_vec_macro_debug(bh: &mut Bencher) { | ||
bh.iter(|| { | ||
let mut mem = Vec::new(); | ||
let wr = &mut mem as &mut dyn io::Write; | ||
for _ in 0..1000 { | ||
write!(wr, "{:?}", "☃").unwrap(); | ||
} | ||
}); | ||
} | ||
|
||
#[bench] | ||
fn write_str_value(bh: &mut Bencher) { | ||
bh.iter(|| { | ||
let mut mem = String::new(); | ||
for _ in 0..1000 { | ||
mem.write_str("abc").unwrap(); | ||
} | ||
}); | ||
} | ||
|
||
#[bench] | ||
fn write_str_ref(bh: &mut Bencher) { | ||
bh.iter(|| { | ||
let mut mem = String::new(); | ||
let wr = &mut mem as &mut dyn fmt::Write; | ||
for _ in 0..1000 { | ||
wr.write_str("abc").unwrap(); | ||
} | ||
}); | ||
} | ||
|
||
#[bench] | ||
fn write_str_macro1(bh: &mut Bencher) { | ||
bh.iter(|| { | ||
let mut mem = String::new(); | ||
for _ in 0..1000 { | ||
write!(mem, "abc").unwrap(); | ||
} | ||
}); | ||
} | ||
|
||
#[bench] | ||
fn write_str_macro2(bh: &mut Bencher) { | ||
bh.iter(|| { | ||
let mut mem = String::new(); | ||
let wr = &mut mem as &mut dyn fmt::Write; | ||
for _ in 0..1000 { | ||
write!(wr, "{}", "abc").unwrap(); | ||
} | ||
}); | ||
} | ||
|
||
#[bench] | ||
fn write_str_macro_debug(bh: &mut Bencher) { | ||
bh.iter(|| { | ||
let mut mem = String::new(); | ||
let wr = &mut mem as &mut dyn fmt::Write; | ||
for _ in 0..1000 { | ||
write!(wr, "{:?}", "☃").unwrap(); | ||
} | ||
}); | ||
} |
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 |
---|---|---|
|
@@ -11,3 +11,4 @@ mod iter; | |
mod num; | ||
mod ops; | ||
mod slice; | ||
mod fmt; |
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
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.