wasm-ticker

Crates.iowasm-ticker
lib.rswasm-ticker
version0.1.2
sourcesrc
created_at2024-09-03 15:51:48.558639
updated_at2024-09-04 21:24:31.793541
descriptionNon-block tick executor for WebAssembly Rust
homepage
repositoryhttps://github.com/fachep/wasm-ticker
max_upload_size
id1361791
size29,388
羊撅撅 (Fachep)

documentation

README

wasm-ticker

Non-block tick executor for WebAssembly Rust.

Ticker callbacks queue as Tasks to JavaScript event loop. Instead of Microtasks or just stacking in, Tasks won't block current host context and UI rendering thread. See also https://developer.mozilla.org/docs/Web/API/HTML_DOM_API/Microtask_guide/in_depth

Ticker API Platform Interval
Browser / Node
MessageChannelTicker Channel Messaging * >4µs / <1µs
ImmediateTicker setImmediate Node ~1µs
TimeoutTicker setTimeout * ~4ms / ~14ms
AnimationFrameTicker requestAnimationFrame Browser According to device
AutoTicker One of above * N/A

Speed Tests:

wasm-pack test --node --release --test speed
# MessageChannelTicker: 10726000/10s, interval: 932ns
# ImmediateTicker: 9051901/10s, interval: 1.104µs
# TimeoutTicker: 664/10s, interval: 15.06024ms
# AutoTicker: 9879000/10s, interval: 1.012µs

wasm-pack test --chrome --release --test speed # with devtools closed
# MessageChannelTicker: 2359423/10s, interval: 4.238µs
# TimeoutTicker: 2140/10s, interval: 4.672897ms
# AnimationFrameTicker: 1438/10s, interval: 6.954102ms
# AutoTicker: 2405336/10s, interval: 4.157µs

wasm-pack test --chrome --release --test speed # with devtools opened
# MessageChannelTicker: 847715/10s, interval: 11.796µs
# TimeoutTicker: 2134/10s, interval: 4.686035ms
# AnimationFrameTicker: 1441/10s, interval: 6.939625ms
# AutoTicker: 860572/10s, interval: 11.62µs
Commit count: 0

cargo fmt