From deee15dd02333282a20804bb070f43127652b127 Mon Sep 17 00:00:00 2001 From: Niket Naidu Date: Fri, 16 May 2025 22:29:30 -0700 Subject: [PATCH 1/2] Updated README --- README.md | 72 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) diff --git a/README.md b/README.md index 9fb83b8..173dee1 100644 --- a/README.md +++ b/README.md @@ -60,6 +60,78 @@ executor.tick(DELTA, Some(1)); assert_eq!(executor.num_tasks(), 0); ``` +# Features + +- `tick_event` +- `timer_registration` + +## Tick Registration + +```rust +#[cfg(feature = "timer_registration")] +{ + use ticked_async_executor::*; + + const DELTA: f64 = 1000.0 / 60.0; + + let mut executor = TickedAsyncExecutor::default(); + + // These APIs are gated under the `timer_registration` feature + let timer = executor.create_timer_from_timer_registration(); + + executor.spawn_local("MyIdentifier1", async move { + timer.sleep_for(10.0).await; + }).detach(); + + executor.wait_till_completed(1.0); + assert_eq!(executor.num_tasks(), 0); +} +``` + +## Tick Event + +```rust +#[cfg(feature = "tick_event")] +{ + use ticked_async_executor::*; + + const DELTA: f64 = 1000.0 / 60.0; + + let mut executor = TickedAsyncExecutor::default(); + + // These APIs are gated under the `tick_event` feature + let _delta_tick_rx = executor.tick_channel(); + let timer = executor.create_timer_from_tick_event(); + + executor.spawn_local("MyIdentifier1", async move { + timer.sleep_for(10.0).await; + }).detach(); + + executor.wait_till_completed(1.0); + assert_eq!(executor.num_tasks(), 0); +} +``` + +# Benchmarks + +- `executor.spawn_local` +``` +Spawn 10000 tasks +time: [1.3711 ms 1.3713 ms 1.3715 ms] +``` + +- `executor.create_timer_from_timer_registration` under feature `timer_registration` +``` +Spawn 1000 timers from timer registration +time: [336.10 µs 336.42 µs 336.93 µs] +``` + +- `executor.create_timer_from_tick_event` under feature `tick_event` +``` +Spawn 1000 timers from tick event +time: [1.5688 ms 1.5692 ms 1.5697 ms] +``` + # Caveats - Uses the `smol` ecosystem From 0ff7889a0aba77d1e08ecdb2d49a0e2df8930110 Mon Sep 17 00:00:00 2001 From: Niket Naidu Date: Fri, 16 May 2025 22:44:34 -0700 Subject: [PATCH 2/2] Updated README --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 173dee1..ce8efa8 100644 --- a/README.md +++ b/README.md @@ -115,19 +115,19 @@ assert_eq!(executor.num_tasks(), 0); # Benchmarks - `executor.spawn_local` -``` +```text Spawn 10000 tasks time: [1.3711 ms 1.3713 ms 1.3715 ms] ``` - `executor.create_timer_from_timer_registration` under feature `timer_registration` -``` +```text Spawn 1000 timers from timer registration time: [336.10 µs 336.42 µs 336.93 µs] ``` - `executor.create_timer_from_tick_event` under feature `tick_event` -``` +```text Spawn 1000 timers from tick event time: [1.5688 ms 1.5692 ms 1.5697 ms] ```