lampbench station / export / label / tm30 / calibrate replace the Python lamp_station.py, lamp_export.py, label_printer.py, tm30.py and calibration.py that lived in HPCS6500-py. The driver is a submodule (HPCS6500/, like mppt-testbench). Workspace crates: tm30 (TM-30-18 port of colour-science 0.4.7), brother-ql (raster protocol, byte-identical to brother_ql) and lamp-label (QR + ID labels for the QL-820NWB). Bundles are byte-identical to lamp_export.py's (golden tests); the station runs end to end in a test against the simulated instrument.
39 lines
1.3 KiB
Rust
39 lines
1.3 KiB
Rust
//! Timing of `tm30::compute` on an HPCS 6500-like input (350 points,
|
|
//! 380-1050 nm). Run with `cargo run -p tm30 --release --example bench`.
|
|
|
|
use std::time::Instant;
|
|
|
|
fn main() {
|
|
// Warm-white LED-like spectrum: blue pump + broad phosphor, on the HPCS
|
|
// 6500 wavelength grid.
|
|
let wl: Vec<f64> = (0..350).map(|i| 380.0 + 670.0 * i as f64 / 349.0).collect();
|
|
let values: Vec<f64> = wl
|
|
.iter()
|
|
.map(|&w| {
|
|
let blue = (-((w - 450.0) / 12.0).powi(2)).exp();
|
|
let phosphor = 1.6 * (-((w - 600.0) / 70.0).powi(2)).exp();
|
|
blue + phosphor
|
|
})
|
|
.collect();
|
|
|
|
let t0 = Instant::now();
|
|
let first = tm30::compute(&wl, &values).expect("valid spectrum");
|
|
let cold = t0.elapsed();
|
|
|
|
let n = 200;
|
|
let t1 = Instant::now();
|
|
let mut rf = 0.0;
|
|
for _ in 0..n {
|
|
rf += tm30::compute(&wl, &values).expect("valid spectrum").rf;
|
|
}
|
|
let warm = t1.elapsed() / n;
|
|
assert!((rf / n as f64 - first.rf).abs() < 1e-12);
|
|
|
|
println!(
|
|
"Rf {:.2} Rg {:.2} CCT {:.0} K Duv {:.4}",
|
|
first.rf, first.rg, first.cct_k, first.duv
|
|
);
|
|
println!("first call (parses tables, builds Planckian table): {cold:?}");
|
|
println!("per call afterwards (mean of {n}): {warm:?}");
|
|
}
|