about summary refs log tree commit diff
path: root/library/test/src/bench.rs
AgeCommit message (Collapse)AuthorLines
2024-09-22Reformat using the new identifier sorting from rustfmtMichael Goulet-2/+2
2024-07-29Reformat `use` declarations.Nicholas Nethercote-11/+8
The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options.
2024-06-20Add blank lines after module-level `//!` comments.Nicholas Nethercote-0/+1
Most modules have such a blank line, but some don't. Inserting the blank line makes it clearer that the `//!` comments are describing the entire module, rather than the `use` declaration(s) that immediately follows.
2024-05-24Run rustfmt on files that need it.Nicholas Nethercote-1/+1
Somehow these files aren't properly formatted. By default `x fmt` and `x tidy` only check files that have changed against master, so if an ill-formatted file somehow slips in it can stay that way as long as it doesn't get modified(?) I found these when I ran `x fmt` explicitly on every `.rs` file in the repo, while working on https://github.com/rust-lang/compiler-team/issues/750.
2024-05-06print walltime benchmarks with subnanosecond precisionThe 8472-10/+13
example results when benchmarking 1-4 serialized ADD instructions ``` running 4 tests test add ... bench: 0.24 ns/iter (+/- 0.00) test add2 ... bench: 0.48 ns/iter (+/- 0.01) test add3 ... bench: 0.72 ns/iter (+/- 0.01) test add4 ... bench: 0.96 ns/iter (+/- 0.01) ```
2022-09-16Do not panic when a test function returns Result::Err.Bradford Hovinen-10/+11
Rust's test library allows test functions to return a Result, so that the test is deemed to have failed if the function returns a Result::Err variant. Currently, this works by having Result implement the Termination trait and asserting in assert_test_result that Termination::report() indicates successful completion. This turns a Result::Err into a panic, which is caught and unwound in the test library. This approach is problematic in certain environments where one wishes to save on both binary size and compute resources when running tests by: * Compiling all code with --panic=abort to avoid having to generate unwinding tables, and * Running most tests in-process to avoid the overhead of spawning new processes. This change removes the intermediate panic step and passes a Result::Err directly through to the test runner. To do this, it modifies assert_test_result to return a Result<(), String> where the Err variant holds what was previously the panic message. It changes the types in the TestFn enum to return Result<(), String>. This tries to minimise the changes to benchmark tests, so it calls unwrap() on the Result returned by assert_test_result, effectively keeping the same behaviour as before.
2021-04-25move core::hint::black_box under its own feature gateRalf Jung-2/+9
2021-03-24libtest: Index tests by a unique TestIdAnders Kaseorg-4/+13
This more robustly avoids problems with duplicate TestDesc. See #81852 and #82274. Signed-off-by: Anders Kaseorg <andersk@mit.edu>
2020-11-10Merge set_panic and set_print into set_output_capture.Mara Bos-9/+5
There were no use cases for setting them separately. Merging them simplifies some things.
2020-11-10Remove io::LocalOutput and use Arc<Mutex<dyn>> for local streams.Mara Bos-6/+2
2020-10-01Fix some clippy issuesJoshua Nelson-1/+1
Found while working on https://github.com/rust-lang/rust/pull/77351; these are just the ones that could be fixed automatically.
2020-09-21Rollup merge of #76959 - est31:write, r=oli-obkRalf Jung-10/+10
Replace write_fmt with write! Latter is simpler
2020-09-20Replace write_fmt with write!est31-10/+10
Latter is simpler
2020-09-20Use as_nanos in bench.rs and base.rsest31-5/+1
2020-07-27mv std libs to library/mark-0/+238