diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2015-12-02 17:31:49 -0800 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2015-12-05 15:09:44 -0800 |
| commit | 464cdff102993ff1900eebbf65209e0a3c0be0d5 (patch) | |
| tree | 12910564caf0946c19be1ac48355210a49b7afee /src/libtest | |
| parent | ac0e84522437331f9a06d04a5842acf0234cc86e (diff) | |
| download | rust-464cdff102993ff1900eebbf65209e0a3c0be0d5.tar.gz rust-464cdff102993ff1900eebbf65209e0a3c0be0d5.zip | |
std: Stabilize APIs for the 1.6 release
This commit is the standard API stabilization commit for the 1.6 release cycle. The list of issues and APIs below have all been through their cycle-long FCP and the libs team decisions are listed below Stabilized APIs * `Read::read_exact` * `ErrorKind::UnexpectedEof` (renamed from `UnexpectedEOF`) * libcore -- this was a bit of a nuanced stabilization, the crate itself is now marked as `#[stable]` and the methods appearing via traits for primitives like `char` and `str` are now also marked as stable. Note that the extension traits themeselves are marked as unstable as they're imported via the prelude. The `try!` macro was also moved from the standard library into libcore to have the same interface. Otherwise the functions all have copied stability from the standard library now. * The `#![no_std]` attribute * `fs::DirBuilder` * `fs::DirBuilder::new` * `fs::DirBuilder::recursive` * `fs::DirBuilder::create` * `os::unix::fs::DirBuilderExt` * `os::unix::fs::DirBuilderExt::mode` * `vec::Drain` * `vec::Vec::drain` * `string::Drain` * `string::String::drain` * `vec_deque::Drain` * `vec_deque::VecDeque::drain` * `collections::hash_map::Drain` * `collections::hash_map::HashMap::drain` * `collections::hash_set::Drain` * `collections::hash_set::HashSet::drain` * `collections::binary_heap::Drain` * `collections::binary_heap::BinaryHeap::drain` * `Vec::extend_from_slice` (renamed from `push_all`) * `Mutex::get_mut` * `Mutex::into_inner` * `RwLock::get_mut` * `RwLock::into_inner` * `Iterator::min_by_key` (renamed from `min_by`) * `Iterator::max_by_key` (renamed from `max_by`) Deprecated APIs * `ErrorKind::UnexpectedEOF` (renamed to `UnexpectedEof`) * `OsString::from_bytes` * `OsStr::to_cstring` * `OsStr::to_bytes` * `fs::walk_dir` and `fs::WalkDir` * `path::Components::peek` * `slice::bytes::MutableByteVector` * `slice::bytes::copy_memory` * `Vec::push_all` (renamed to `extend_from_slice`) * `Duration::span` * `IpAddr` * `SocketAddr::ip` * `Read::tee` * `io::Tee` * `Write::broadcast` * `io::Broadcast` * `Iterator::min_by` (renamed to `min_by_key`) * `Iterator::max_by` (renamed to `max_by_key`) * `net::lookup_addr` New APIs (still unstable) * `<[T]>::sort_by_key` (added to mirror `min_by_key`) Closes #27585 Closes #27704 Closes #27707 Closes #27710 Closes #27711 Closes #27727 Closes #27740 Closes #27744 Closes #27799 Closes #27801 cc #27801 (doesn't close as `Chars` is still unstable) Closes #28968
Diffstat (limited to 'src/libtest')
| -rw-r--r-- | src/libtest/lib.rs | 52 |
1 files changed, 23 insertions, 29 deletions
diff --git a/src/libtest/lib.rs b/src/libtest/lib.rs index 71eddd80c74..7ffe567ac83 100644 --- a/src/libtest/lib.rs +++ b/src/libtest/lib.rs @@ -37,13 +37,12 @@ #![feature(asm)] #![feature(box_syntax)] -#![feature(duration_span)] #![feature(fnbox)] -#![feature(iter_cmp)] #![feature(libc)] #![feature(rustc_private)] #![feature(set_stdio)] #![feature(staged_api)] +#![feature(time2)] extern crate getopts; extern crate serialize; @@ -79,7 +78,7 @@ use std::path::PathBuf; use std::sync::mpsc::{channel, Sender}; use std::sync::{Arc, Mutex}; use std::thread; -use std::time::Duration; +use std::time::{Instant, Duration}; // to be used by rustc to compile tests in libtest pub mod test { @@ -714,7 +713,7 @@ pub fn run_tests_console(opts: &TestOpts, tests: Vec<TestDescAndFn> ) -> io::Res PadOnRight => t.desc.name.as_slice().len(), } } - match tests.iter().max_by(|t|len_if_padded(*t)) { + match tests.iter().max_by_key(|t|len_if_padded(*t)) { Some(t) => { let n = t.desc.name.as_slice(); st.max_name_len = n.len(); @@ -1121,12 +1120,12 @@ pub fn black_box<T>(dummy: T) -> T { dummy } impl Bencher { /// Callback for benchmark functions to run in their body. pub fn iter<T, F>(&mut self, mut inner: F) where F: FnMut() -> T { - self.dur = Duration::span(|| { - let k = self.iterations; - for _ in 0..k { - black_box(inner()); - } - }); + let start = Instant::now(); + let k = self.iterations; + for _ in 0..k { + black_box(inner()); + } + self.dur = start.elapsed(); } pub fn ns_elapsed(&mut self) -> u64 { @@ -1169,29 +1168,24 @@ impl Bencher { let mut total_run = Duration::new(0, 0); let samples : &mut [f64] = &mut [0.0_f64; 50]; loop { - let mut summ = None; - let mut summ5 = None; + let loop_start = Instant::now(); - let loop_run = Duration::span(|| { - - for p in &mut *samples { - self.bench_n(n, |x| f(x)); - *p = self.ns_per_iter() as f64; - }; + for p in &mut *samples { + self.bench_n(n, |x| f(x)); + *p = self.ns_per_iter() as f64; + }; - stats::winsorize(samples, 5.0); - summ = Some(stats::Summary::new(samples)); + stats::winsorize(samples, 5.0); + let summ = stats::Summary::new(samples); - for p in &mut *samples { - self.bench_n(5 * n, |x| f(x)); - *p = self.ns_per_iter() as f64; - }; + for p in &mut *samples { + self.bench_n(5 * n, |x| f(x)); + *p = self.ns_per_iter() as f64; + }; - stats::winsorize(samples, 5.0); - summ5 = Some(stats::Summary::new(samples)); - }); - let summ = summ.unwrap(); - let summ5 = summ5.unwrap(); + stats::winsorize(samples, 5.0); + let summ5 = stats::Summary::new(samples); + let loop_run = loop_start.elapsed(); // If we've run for 100ms and seem to have converged to a // stable median. |
