File: bench.rs

package info (click to toggle)
rust-nutmeg 0.1.4-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 352 kB
  • sloc: makefile: 2
file content (20 lines) | stat: -rw-r--r-- 520 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
//! See how fast we can send view updates.
//!
//! (Run this with `--release` to get a fair estimate.)

use std::time::Instant;

fn main() {
    let start = Instant::now();
    let view = nutmeg::View::new(0u64, nutmeg::Options::default());
    let n = 10_000_000;
    for i in 0..n {
        view.update(|model| *model = i);
    }
    view.message(format!(
        "{}ms to send {} updates; average {}ns/update",
        start.elapsed().as_millis(),
        n,
        start.elapsed().as_nanos() / n as u128,
    ));
}