Crates.io | wasm-ticker |
lib.rs | wasm-ticker |
version | 0.1.2 |
source | src |
created_at | 2024-09-03 15:51:48.558639 |
updated_at | 2024-09-04 21:24:31.793541 |
description | Non-block tick executor for WebAssembly Rust |
homepage | |
repository | https://github.com/fachep/wasm-ticker |
max_upload_size | |
id | 1361791 |
size | 29,388 |
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 |
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