summary refs log tree commit diff
path: root/src/libcoretest
AgeCommit message (Collapse)AuthorLines
2015-07-28Auto merge of #27280 - bluss:siphash-perf, r=alexcrichtonbors-3/+87
Improve siphash performance for longer data Use `ptr::copy_nonoverlapping` (aka memcpy) to load an u64 from the byte stream. This is correct for any alignment, and the compiler will use the appropriate instruction to load the data. Also contains small tweaks that should benefit hashing short data too, both the commit that removes a variable and the autovectorization of the hash state initialization (in SipHash::reset). Benchmarks show that hashing longer data benefits for the improved word loading. Before (using benchmarks from the first commit in the PR): The before benchmark is a bit noisy. ``` test hash::sip::bench_bytes_4 ... bench: 41 ns/iter (+/- 0) = 97 MB/s test hash::sip::bench_bytes_7 ... bench: 49 ns/iter (+/- 2) = 142 MB/s test hash::sip::bench_bytes_8 ... bench: 42 ns/iter (+/- 4) = 190 MB/s test hash::sip::bench_bytes_a_16 ... bench: 57 ns/iter (+/- 14) = 280 MB/s test hash::sip::bench_bytes_b_32 ... bench: 85 ns/iter (+/- 74) = 376 MB/s test hash::sip::bench_bytes_c_128 ... bench: 278 ns/iter (+/- 33) = 460 MB/s test hash::sip::bench_long_str ... bench: 825 ns/iter (+/- 103) test hash::sip::bench_str_of_8_bytes ... bench: 151 ns/iter (+/- 66) test hash::sip::bench_str_over_8_bytes ... bench: 59 ns/iter (+/- 3) test hash::sip::bench_str_under_8_bytes ... bench: 47 ns/iter (+/- 56) test hash::sip::bench_u32 ... bench: 39 ns/iter (+/- 93) = 205 MB/s test hash::sip::bench_u32_keyed ... bench: 40 ns/iter (+/- 88) = 200 MB/s test hash::sip::bench_u64 ... bench: 54 ns/iter (+/- 96) = 148 MB/s ``` After: ``` test hash::sip::bench_bytes_4 ... bench: 41 ns/iter (+/- 3) = 97 MB/s test hash::sip::bench_bytes_7 ... bench: 48 ns/iter (+/- 0) = 145 MB/s test hash::sip::bench_bytes_8 ... bench: 35 ns/iter (+/- 1) = 228 MB/s test hash::sip::bench_bytes_a_16 ... bench: 45 ns/iter (+/- 1) = 355 MB/s test hash::sip::bench_bytes_b_32 ... bench: 60 ns/iter (+/- 0) = 533 MB/s test hash::sip::bench_bytes_c_128 ... bench: 161 ns/iter (+/- 5) = 795 MB/s test hash::sip::bench_long_str ... bench: 514 ns/iter (+/- 5) test hash::sip::bench_str_of_8_bytes ... bench: 44 ns/iter (+/- 0) test hash::sip::bench_str_over_8_bytes ... bench: 51 ns/iter (+/- 0) test hash::sip::bench_str_under_8_bytes ... bench: 52 ns/iter (+/- 6) test hash::sip::bench_u32 ... bench: 40 ns/iter (+/- 2) = 200 MB/s test hash::sip::bench_u32_keyed ... bench: 39 ns/iter (+/- 1) = 205 MB/s test hash::sip::bench_u64 ... bench: 36 ns/iter (+/- 1) = 222 MB/s ```
2015-07-25siphash: Add more benchmarksUlrik Sverdrup-3/+87
2015-07-20Auto merge of #27026 - nagisa:overflowing-unsigned, r=pnkfelixbors-2/+0
This commit fixes the negate_unsigned feature gate to appropriately account for inferred variables. This is technically a [breaking-change], but I’d consider it a bug fix. cc @brson for your relnotes. Fixes https://github.com/rust-lang/rust/issues/24676 Fixes #26840 Fixes https://github.com/rust-lang/rust/issues/25206
2015-07-19optimize from_str_radixarthurprs-2/+9
2015-07-14Fix negate_unsigned feature gate checkSimonas Kazlauskas-2/+0
This commit fixes the negate_unsigned feature gate to appropriately account for infered variables. This is technically a [breaking-change].
2015-07-14core: Revive SipHash's testsUlrik Sverdrup-67/+61
These tests were bitrotting, include them in the crate and bring them up to date and compiling.. and they pass.
2015-07-09Use vec![elt; n] where possibleUlrik Sverdrup-3/+2
The common pattern `iter::repeat(elt).take(n).collect::<Vec<_>>()` is exactly equivalent to `vec![elt; n]`, do this replacement in the whole tree. (Actually, vec![] is smart enough to only call clone n - 1 times, while the former solution would call clone n times, and this fact is virtually irrelevant in practice.)
2015-06-30std: Fix formatting flags for charsAlex Crichton-0/+2
This recently regressed in #24689, and this updates the `Display` implementation to take formatting flags into account. Closes #26625
2015-06-24Remove char::to_titlecase. Fix #26555Simon Sapin-23/+0
I added it because it was easy (same a `char::to_lowercase`, just a different table), but it doesn’t make sense to have this in std but not str::to_titlecase, which would require https://github.com/unicode-rs/unicode-segmentation At some point in the future this feature will be available (both on char and str) in a crates.io crate.
2015-06-17Fallout in tests and docs from feature renamingsAlex Crichton-17/+35
2015-06-15Auto merge of #25359 - thepowersgang:result-expect-2, r=alexcrichtonbors-0/+14
As it says in the title. I've added an `expect` method to `Result` that allows printing both an error message (e.g. what operation was attempted), and the error value. This is separate from the `unwrap` and `ok().expect("message")` behaviours.
2015-06-15libcore/Result - RFC#1119 Add an 'expect' method to ResultJohn Hodge-0/+14
2015-06-10Removed many pointless calls to *iter() and iter_mut()Joshua Landau-17/+17
2015-06-09Move collectionstest::char into coretest::charSimon Sapin-0/+28
2015-06-09Fix coretest::char::test_to_uppercase for complex mappingSimon Sapin-18/+17
2015-05-30Auto merge of #25817 - XMPPwocky:once_cleanedup, r=alexcrichtonbors-0/+15
Closes #24443.
2015-05-29Implement RFC 771: std::iter::onceNathaniel Theis-0/+15
2015-05-29add const_fn featuresNiko Matsakis-0/+1
2015-05-29Add map and filter_map associated functions to std::cell::Ref and RefMutSimon Sapin-0/+77
See design discussion in https://github.com/rust-lang/rust/pull/25747
2015-05-28Move std::cell::clone_ref to a clone associated function on std::cell::RefSimon Sapin-2/+2
... and generalize the bounds on the value type.
2015-05-27Use `const fn` to abstract away the contents of UnsafeCell & friends.Eduard Burtescu-4/+6
2015-05-19Stabilize debug builders for 1.2.0Steven Fackler-1/+0
2015-05-13RebasingNick Cameron-11/+12
2015-05-09Auto merge of #24612 - lifthrasiir:flt2dec, r=pnkfelixbors-0/+1696
This is a direct port of my prior work on the float formatting. The detailed description is available [here](https://github.com/lifthrasiir/rust-strconv#flt2dec). In brief, * This adds a new hidden module `core::num::flt2dec` for testing from `libcoretest`. Why is it in `core::num` instead of `core::fmt`? Because I envision that the table used by `flt2dec` is directly applicable to `dec2flt` (cf. #24557) as well, which exceeds the realm of "formatting". * This contains both Dragon4 algorithm (exact, complete but slow) and Grisu3 algorithm (exact, fast but incomplete). * The code is accompanied with a large amount of self-tests and some exhaustive tests. In particular, `libcoretest` gets a new dependency on `librand`. For the external interface it relies on the existing test suite. * It is known that, in the best case, the entire formatting code has about 30 KBs of binary overhead (judged from strconv experiments). Not too bad but there might be a potential room for improvements. This is rather large code. I did my best to comment and annotate the code, but you have been warned. For the maximal availability the original code was licensed in CC0, but I've also dual-licensed it in MIT/Apache as well so there should be no licensing concern. This is [breaking-change] as it changes the float output slightly (and it also affects the casing of `inf` and `nan`). I hope this is not a big deal though :) Fixes #7030, #18038 and #24556. Also related to #6220 and #20870. ## Known Issues - [x] I've yet to finish `make check-stage1`. It does pass main test suites including `run-pass` but there might be some unknown edges on the doctests. - [ ] Figure out how this PR affects rustc. - [ ] Determine which internal routine is mapped to the formatting specifier. Depending on the decision, some internal routine can be safely removed (for instance, currently `to_shortest_str` is unused).
2015-05-06core: use banker's rounding for the exact mode in flt2dec.Kang Seonghoon-5/+18
For the shortest mode the IEEE 754 decoder already provides an exact rounding range accounting for banker's rounding, but it was not the case for the exact mode. This commit alters the exact mode algorithm for Dragon so that any number ending at `...x5000...` with even `x` and infinite zeroes will round to `...x` instead of `...(x+1)` as it was. Grisu is not affected by this change because this halfway case always results in the failure for Grisu.
2015-05-06core: updated for the master changes.Kang Seonghoon-98/+91
The master no longer has `std::num::Float`, so a generic `ldexp` is not readily available. `DecodableFloat::ldexpi` works around this.
2015-05-06core: fixed a slight bug.Kang Seonghoon-3/+17
The bug involves the incorrect logic for `core::num::flt2dec::decoder`. This makes some numbers in the form of 2^n missing one final digits, which breaks the bijectivity criterion. The regression tests have been added, and f32 exhaustive test is rerun to get the updated result.
2015-05-06core: fixed typos and revised comments in flt2dec.Kang Seonghoon-1/+1
2015-05-06core: tweaked flt2dec to match the casing of the older formatting code.Kang Seonghoon-32/+32
2015-05-06core: added core::num::flt2dec for floating-point formatting.Kang Seonghoon-0/+1676
This is a fork of the flt2dec portion of rust-strconv [1] with a necessary relicensing (the original code was licensed CC0-1.0). Each module is accompanied with large unit tests, integrated in this commit as coretest::num::flt2dec. This module is added in order to replace the existing core::fmt::float method. The forked revision of rust-strconv is from 2015-04-20, with a commit ID 9adf6d3571c6764a6f240a740c823024f70dc1c7. [1] https://github.com/lifthrasiir/rust-strconv/
2015-05-05Optimize iterator adapters.Steven Allen-0/+215
Specifically, make count, nth, and last call the corresponding methods on the underlying iterator where possible. This way, if the underlying iterator has an optimized count, nth, or last implementations (e.g. slice::Iter), these methods will propagate these optimizations. Additionally, change Skip::next to take advantage of a potentially optimized nth method on the underlying iterator.
2015-05-03Auto merge of #24737 - P1start:dst-cell, r=alexcrichtonbors-0/+24
This + DST coercions (#24619) would allow code like `Rc<RefCell<Box<Trait>>>` to be simplified to `Rc<RefCell<Trait>>`.
2015-05-01Auto merge of #25006 - alexcrichton:unstable-indexing, r=aturonbors-49/+0
These implementations were intended to be unstable, but currently the stability attributes cannot handle a stable trait with an unstable `impl` block. This commit also audits the rest of the standard library for explicitly-`#[unstable]` impl blocks. No others were removed but some annotations were changed to `#[stable]` as they're defacto stable anyway. One particularly interesting `impl` marked `#[stable]` as part of this commit is the `Add<&[T]>` impl for `Vec<T>`, which uses `push_all` and implicitly clones all elements of the vector provided. Closes #24791 [breaking-change]
2015-05-02Make `UnsafeCell`, `RefCell`, `Mutex`, and `RwLock` accept DSTsP1start-0/+24
This + DST coercions (#24619) would allow code like `Rc<RefCell<Box<Trait>>>` to be simplified to `Rc<RefCell<Trait>>`.
2015-05-01std: Remove index notation on slice iteratorsAlex Crichton-49/+0
These implementations were intended to be unstable, but currently the stability attributes cannot handle a stable trait with an unstable `impl` block. This commit also audits the rest of the standard library for explicitly-`#[unstable]` impl blocks. No others were removed but some annotations were changed to `#[stable]` as they're defacto stable anyway. One particularly interesting `impl` marked `#[stable]` as part of this commit is the `Add<&[T]>` impl for `Vec<T>`, which uses `push_all` and implicitly clones all elements of the vector provided. Closes #24791
2015-05-01Auto merge of #24720 - critiqjo:stepby-sizehint, r=alexcrichtonbors-1/+13
`Iterator::size_hint` can be easily implemented for `StepBy`. #23708
2015-05-01iterator: Add `StepBy::size_hint` methodcritiqjo-1/+13
Fixes `Step::steps_between` implementations by integer types to correctly handle `by != 1`.
2015-04-28Unstub some testsTamir Duberstein-4/+1
2015-04-28Tests need not be publicTamir Duberstein-11/+11
2015-04-28Remove unused variableTamir Duberstein-9/+7
2015-04-29Auto merge of #24888 - tamird:snapshot, r=alexcrichtonbors-3/+1
r? @alexcrichton cc @brson
2015-04-28Register new snapshotsTamir Duberstein-3/+1
2015-04-29Auto merge of #24865 - bluss:range-size, r=alexcrichtonbors-0/+6
core: Fix size_hint for signed integer `Range<T>` iterators There was an overflow bug in .size_hint() for signed iterators, which produced an hilariously incorrect size or an overflow panic. Incorrect size is a serious bug since the iterators are marked ExactSizeIterator. (And leads to abort() on (-1i8..127).collect() when the collection tries to preallocate too much). > (-1i8..127).size_hint() (18446744073709551488, Some(18446744073709551488)) Bug found using quickcheck. Fixes #24851
2015-04-27Auto merge of #24701 - Stebalien:slice, r=alexcrichtonbors-0/+31
Instead of using the O(n) defaults, define O(1) shortcuts. I also copied (and slightly modified) the relevant tests from the iter tests into the slice tests just in case someone comes along and changes them in the future. Partially implements #24214.
2015-04-27core: Fix size_hint for signed integer Range<T> iteratorsUlrik Sverdrup-0/+6
There was an overflow bug in .size_hint() for signed iterators, which produced an hilariously incorrect size or an overflow panic. Incorrect size is a serious bug since the iterators are marked ExactSizeIterator. (And leads to abort() on (-1i8..127).collect() when the collection tries to preallocate too much). All signed range iterators were affected. > (-1i8..127).size_hint() (18446744073709551488, Some(18446744073709551488)) Bug found using quickcheck. Fixes #24851
2015-04-24Change name of unit test sub-module to "tests".Johannes Oertel-1/+1
Changes the style guidelines regarding unit tests to recommend using a sub-module named "tests" instead of "test" for unit tests as "test" might clash with imports of libtest.
2015-04-22Implement O(1) slice::Iter methods.Steven Allen-0/+31
Instead of using the O(n) defaults, define O(1) shortcuts.
2015-04-21std: Bring back f32::from_str_radix as an unstable APIAlex Crichton-84/+60
This API was exercised in a few tests and mirrors the `from_str_radix` functionality of the integer types.
2015-04-21Model lexer: Fix remaining issuesPiotr Czarnecki-2/+0
2015-04-16deprecate Unicode functions that will be moved to crates.iokwantam-1/+2
This patch 1. renames libunicode to librustc_unicode, 2. deprecates several pieces of libunicode (see below), and 3. removes references to deprecated functions from librustc_driver and libsyntax. This may change pretty-printed output from these modules in cases involving wide or combining characters used in filenames, identifiers, etc. The following functions are marked deprecated: 1. char.width() and str.width(): --> use unicode-width crate 2. str.graphemes() and str.grapheme_indices(): --> use unicode-segmentation crate 3. str.nfd_chars(), str.nfkd_chars(), str.nfc_chars(), str.nfkc_chars(), char.compose(), char.decompose_canonical(), char.decompose_compatible(), char.canonical_combining_class(): --> use unicode-normalization crate