Registry / RepositoryTypeScriptRustPython
Rollpie
ReadmeFiles
Versions
Info
Download
0.2.0579.9 KB2026-09-150.1.1576.6 KB2026-09-12
Version
0.1.1
Copyright
Rollpie, Irohabook
Publisher
math
Published
2026-09-12
Size
576.6 KB
Downloads
4
Checksum
8e0181e42f4abdc9f91c1ff48b058761bf1940be8d2d4747e5e74bd3014f4322
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
use std::time::Instant;
use suki::{Mode, Shape};

fn main() {
    let start = Instant::now();
    let data = std::fs::read("font/latinmodern-math.otf").unwrap();
    let read = start.elapsed();
    let start = Instant::now();
    let font = suki::load_font(data).unwrap();
    let load = start.elapsed();

    let sources = [
        r"x^2 + y^2 = r^2",
        r"x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}",
        r"\sum_{k=1}^{n} k = \frac{n(n+1)}{2}",
        r"\begin{pmatrix} a & b \\ c & d \end{pmatrix}",
        r"\left( \frac{1}{\sqrt{\frac{a}{b} + \frac{c}{d}}} \right)",
    ];
    let rounds = 2000;
    let start = Instant::now();
    let mut total = 0usize;

    for _ in 0..rounds {
        for source in sources {
            total += suki::render_svg(source, &font, Mode::Display, Shape::Outline).unwrap().len();
        }
    }

    let render = start.elapsed();
    let count = rounds * sources.len();
    println!("ファイル読み込み {read:?}");
    println!("フォント読み込み {load:?}");
    println!("組み上げ {count} 式で {render:?}(1 式あたり {:?})", render / count as u32);
    println!("書き出した文字数 {total}");
}