Skip to main content

kpsetime/
kpsetime.rs

1//! Times kpathsea initialization and a few lookups.
2use retex_kpath::{FileFormat, Kpathsea, Options};
3
4fn main() {
5    let t = std::time::Instant::now();
6    let mut o = Options::lualatex();
7    o.cache_dir = Some(std::env::temp_dir().join("retex-kpse-test"));
8    let mut k = Kpathsea::new(o).unwrap();
9    let init = t.elapsed();
10    let t = std::time::Instant::now();
11    for n in [
12        "latex.ltx",
13        "article.cls",
14        "size10.clo",
15        "lmroman10-regular.otf",
16        "ltluatex.lua",
17    ] {
18        let f = if n.ends_with(".otf") {
19            FileFormat::OpenType
20        } else if n.ends_with(".lua") {
21            FileFormat::Lua
22        } else {
23            FileFormat::Tex
24        };
25        let _ = k.find_file(n, f);
26    }
27    println!("init {init:?}, 5 lookups {:?}", t.elapsed());
28}