about summary refs log tree commit diff
path: root/library/std/src/time
AgeCommit message (Collapse)AuthorLines
2025-01-26Move std::time unit tests to integration testsbjorn3-274/+0
2024-09-22Reformat using the new identifier sorting from rustfmtMichael Goulet-2/+2
2024-07-29Reformat `use` declarations.Nicholas Nethercote-1/+3
The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options.
2023-05-05Rollup merge of #103056 - beetrees:timespec-bug-fix, r=thomccDylan DPC-0/+27
Fix `checked_{add,sub}_duration` incorrectly returning `None` when `other` has more than `i64::MAX` seconds Use `checked_{add,sub}_unsigned` in `checked_{add,sub}_duration` so that the correct result is returned when adding/subtracting durations with more than `i64::MAX` seconds.
2022-11-13Fix non-associativity of `Instant` math on `aarch64-apple-darwin` targetsJoy-0/+8
2022-10-14Fix `checked_{add,sub}_duration` incorrectly returning `None` when `other` ↵beetrees-0/+27
has more than `i64::MAX` seconds
2022-08-18make many std tests work in MiriRalf Jung-1/+2
2022-03-10Use implicit capture syntax in format_argsT-O-R-U-S-3/+3
This updates the standard library's documentation to use the new syntax. The documentation is worthwhile to update as it should be more idiomatic (particularly for features like this, which are nice for users to get acquainted with). The general codebase is likely more hassle than benefit to update: it'll hurt git blame, and generally updates can be done by folks updating the code if (and when) that makes things more readable with the new format. A few places in the compiler and library code are updated (mostly just due to already having been done when this commit was first authored).
2022-02-13make Instant::{duration_since, elapsed, sub} saturating and remove workaroundsThe8472-144/+3
This removes all mutex/atomics based workarounds for non-monotonic clocks and makes the previously panicking methods saturating instead. Effectively this moves the monotonization from `Instant` construction to the comparisons. This has some observable effects, especially on platforms without monotonic clocks: * Incorrectly ordered Instant comparisons no longer panic. This may hide some programming errors until someone actually looks at the resulting `Duration` * `checked_duration_since` will now return `None` in more cases. Previously it only happened when one compared instants obtained in the wrong order or manually created ones. Now it also does on backslides. The upside is reduced complexity and lower overhead of `Instant::now`.
2021-10-30Add #[must_use] to remaining std functions (O-Z)John Kugelman-2/+2
2021-10-04Rollup merge of #88651 - AGSaidi:monotonize-inner-64b-aarch64, r=dtolnayManish Goregaokar-2/+2
Use the 64b inner:monotonize() implementation not the 128b one for aarch64 aarch64 prior to v8.4 (FEAT_LSE2) doesn't have an instruction that guarantees untorn 128b reads except for completing a 128b load/store exclusive pair (ldxp/stxp) or compare-and-swap (casp) successfully. The requirement to complete a 128b read+write atomic is actually more expensive and more unfair than the previous implementation of monotonize() which used a Mutex on aarch64, especially at large core counts. For aarch64 switch to the 64b atomic implementation which is about 13x faster for a benchmark that involves many calls to Instant::now().
2021-09-17use AtomicU64::fetch_update instead of handrolled RMW-loopThe8472-14/+9
2021-09-16fix potential race in AtomicU64 time monotonizerThe8472-28/+34
2021-09-04Use the 64b inner:monotonize() implementation not the 128b one for aarch64Ali Saidi-2/+2
aarch64 prior to v8.4 (FEAT_LSE2) doesn't have an instruction that guarantees untorn 128b reads except for completing a 128b load/store exclusive pair (ldxp/stxp) or compare-and-swap (casp) successfully. The requirement to complete a 128b read+write atomic is actually more expensive and more unfair than the previous implementation of monotonize() which used a Mutex on aarch64, especially at large core counts. For aarch64 switch to the 64b atomic implementation which is about 13x faster for a benchmark that involves many calls to Instant::now().
2021-08-22Fix typos “an”→“a” and a few different ones that appeared in the ↵Frank Steffahn-1/+1
same search
2021-08-20fix tests on wasm targets that have 32bit time_t and don't have threadsThe8472-2/+12
2021-08-17[review] fix commentthe8472-1/+1
Co-authored-by: Amanieu d'Antras <amanieu@gmail.com>
2021-08-16correct overflows in the backslide case, add testThe8472-8/+48
2021-08-16Apply suggestions from code reviewthe8472-2/+2
Co-authored-by: Amanieu d'Antras <amanieu@gmail.com>
2021-08-13add benchmarks for 1, 2, 4, 8, 16 threadsThe8472-0/+43
2021-08-13where available use 64- or 128bit atomics instead of a Mutex to monotonize timeThe8472-2/+120
2020-10-21Duration::zero() -> Duration::ZEROJubilee Young-3/+3
Duration::ZERO composes better with match and various other things, at the cost of an occasional parens, and results in less work for the optimizer, so let's use that instead.
2020-10-21Dogfood Duration API in std::time testsJubilee Young-16/+16
This expands time's test suite to use more and in more places the range of methods and constants added to Duration in recent proposals for the sake of testing more API surface area and improving legibility.
2020-08-31std: move "mod tests/benches" to separate filesLzu Tao-0/+165
Also doing fmt inplace as requested.