Registry / RepositoryTypeScriptRustPython
Rollpie
ReadmeFiles
Versions
Info
Download
0.2.0528.5 KB2026-10-160.1.1542.8 KB2026-10-150.1.0541.1 KB2026-10-15
Version
0.1.1
Copyright
Rollpie, Irohabook
Publisher
math
Published
2026-10-15
Size
542.8 KB
Downloads
9
Checksum
2e36f65a5798a2a0281457d1ed7f5a4e1a74967fea2880b4961ede38808a3682
Dependencies
None

bench.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
//! Measures the speed of loading and building
//!
//! Usage:
//!   cargo run --release --example bench

use std::time::Instant;


const DEFAULT_FONT: &str = "font/latinmodern-math.otf";


const SAMPLES: &[&str] = &[
    "H-O-H",
    "O=C=O",
    "H_3C-CH_2-OH",
    "H_3C-C(=[:90]O)-OH",
    "*6(-=-=-=)",
    "**6(------)",
    "*6(--?[a]-(-[:0]-[:60]-[:120]-[:180]?[a])---)",
    "H_3C-C(>[:90]OH)(<:[:-90]H)-CH_2-CH_3",
];


fn main() {
    let data = std::fs::read(DEFAULT_FONT).expect("試験用のフォントを読めません");

    let start = Instant::now();
    let font = lina::load_font(data).expect("フォントを読み込めません");
    let loading = start.elapsed();

    // Run everything once before measuring, so that first-run costs are not included
    for source in SAMPLES {
        lina::render_svg(source, &font).expect(source);
    }

    let rounds = 1000;
    let start = Instant::now();

    for _ in 0..rounds {
        for source in SAMPLES {
            lina::render_svg(source, &font).expect(source);
        }
    }

    let total = start.elapsed();
    let each = total.as_secs_f64() / (rounds * SAMPLES.len()) as f64;

    println!("読み込み    {:.1} ミリ秒", loading.as_secs_f64() * 1000.0);
    println!("組み上げ    {:.1} マイクロ秒(分子 1 つあたり)", each * 1_000_000.0);
    println!("見本の数    {}", SAMPLES.len());
}