]> git.lizzy.rs Git - rust.git/blob - src/doc/unstable-book/src/compiler-flags/report-time.md
Rollup merge of #93613 - crlf0710:rename_to_async_iter, r=yaahc
[rust.git] / src / doc / unstable-book / src / compiler-flags / report-time.md
1 # `report-time`
2
3 The tracking issue for this feature is: [#64888]
4
5 [#64888]: https://github.com/rust-lang/rust/issues/64888
6
7 ------------------------
8
9 The `report-time` feature adds a possibility to report execution time of the
10 tests generated via `libtest`.
11
12 This is unstable feature, so you have to provide `-Zunstable-options` to get
13 this feature working.
14
15 Sample usage command:
16
17 ```sh
18 ./test_executable -Zunstable-options --report-time
19 ```
20
21 Available options:
22
23 ```sh
24 --report-time
25                 Show execution time of each test.
26                 Threshold values for colorized output can be
27                 configured via
28                 `RUST_TEST_TIME_UNIT`, `RUST_TEST_TIME_INTEGRATION`
29                 and
30                 `RUST_TEST_TIME_DOCTEST` environment variables.
31                 Expected format of environment variable is
32                 `VARIABLE=WARN_TIME,CRITICAL_TIME`.
33                 Not available for --format=terse
34 --ensure-time
35                 Treat excess of the test execution time limit as
36                 error.
37                 Threshold values for this option can be configured via
38                 `RUST_TEST_TIME_UNIT`, `RUST_TEST_TIME_INTEGRATION`
39                 and
40                 `RUST_TEST_TIME_DOCTEST` environment variables.
41                 Expected format of environment variable is
42                 `VARIABLE=WARN_TIME,CRITICAL_TIME`.
43                 `CRITICAL_TIME` here means the limit that should not be
44                 exceeded by test.
45 ```
46
47 Example of the environment variable format:
48
49 ```sh
50 RUST_TEST_TIME_UNIT=100,200
51 ```
52
53 where 100 stands for warn time, and 200 stands for critical time.
54
55 ## Examples
56
57 ```sh
58 cargo test --tests -- -Zunstable-options --report-time
59     Finished dev [unoptimized + debuginfo] target(s) in 0.02s
60      Running target/debug/deps/example-27fb188025bec02c
61
62 running 3 tests
63 test tests::unit_test_quick ... ok <0.000s>
64 test tests::unit_test_warn ... ok <0.055s>
65 test tests::unit_test_critical ... ok <0.110s>
66
67 test result: ok. 3 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
68
69      Running target/debug/deps/tests-cedb06f6526d15d9
70
71 running 3 tests
72 test unit_test_quick ... ok <0.000s>
73 test unit_test_warn ... ok <0.550s>
74 test unit_test_critical ... ok <1.100s>
75
76 test result: ok. 3 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
77 ```