| Crates.io | future-timing |
| lib.rs | future-timing |
| version | 0.1.0 |
| created_at | 2025-03-12 13:52:34.835278+00 |
| updated_at | 2025-03-12 13:52:34.835278+00 |
| description | Future timing instrumentation. Instrumentation to record the busy and idle time taken by a future as it is driven to completion. |
| homepage | https://github.com/hds/future-timing |
| repository | https://github.com/hds/future-timing |
| max_upload_size | |
| id | 1589768 |
| size | 28,956 |
Future timing instrumentation.
Provides instrumentation to record the time taken by a future. This includes the busy time and the idle time.
The busy time of a future is the sum of all the time consumed during calls to [Future::poll]
on that future.
The idle time of a future is the sum of all the time between calls to [Future::poll]. The
time before the first poll is not included.
First, add this to your Cargo.toml dependencies:
future-timing = "0.1"
Record the timing of a future in the following manner.
let output = future_timing::timed(some_async_fn()).await;
let (timing, future_output) = output.into_parts();
do_something_with_output(future_output);
assert!(!timing.idle().is_zero());
assert!(!timing.busy().is_zero());
This is a single purpose crate, created because I couldn't find any other crate that included the functionality I needed, which is to say, record future timing and make it available to the code that awaited the future upon that future resolving.
If you want to record and analyze the timing of many different futures (and you're using the
Tokio runtime, then you can use Tokio's RuntimeMetrics for an aggregated view or Tokio
Console to see the timings of each task individually.
If you don't actualy want to record the timing of a future, but instead want a future which
resolves after a specific period of time, then you're in the wrong place. Have a look at the
async-timer crate instead.
future-timing is built against the latest stable release. The minimum supported version is
1.70. The current version of future-timing is not guaranteed to build on Rust versions earlier
than the minimum supported version.
This project is licensed under the MIT license.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion
in future-timing by you, shall be licensed as MIT, without any additional terms or conditions.