Struct pconvert_rust::benchmark::Benchmark
source · pub struct Benchmark { /* private fields */ }Expand description
Holds the times for read, write and blend operations.
Implementations§
source§impl Benchmark
impl Benchmark
sourcepub fn total(&self) -> f64
pub fn total(&self) -> f64
Returns the total time (in milliseconds), i.e., the sum of read, write and blend times.
sourcepub fn execute<F, T, H>(&mut self, update_fn: H, target_fn: F) -> Twhere
F: FnOnce() -> T,
H: FnOnce(&mut Self, f64),
pub fn execute<F, T, H>(&mut self, update_fn: H, target_fn: F) -> Twhere F: FnOnce() -> T, H: FnOnce(&mut Self, f64),
Executes the function to benchmark and adds the time spent
to a certain counter with the given target_fn.
use pconvert_rust::benchmark::Benchmark;
use pconvert_rust::utils::read_png_from_file;
let mut benchmark = Benchmark::new();
let demultiply = false;
let path = "path/to/file.png".to_owned();
let top = benchmark.execute(Benchmark::add_read_png_time, || {
read_png_from_file(path, demultiply)
}).unwrap();sourcepub fn add_blend_time(benchmark: &mut Benchmark, blend_time: f64)
pub fn add_blend_time(benchmark: &mut Benchmark, blend_time: f64)
Adds time spent blending to the blend time counter.
sourcepub fn add_read_png_time(benchmark: &mut Benchmark, read_png_time: f64)
pub fn add_read_png_time(benchmark: &mut Benchmark, read_png_time: f64)
Adds time spent reading to the read time counter.
sourcepub fn add_write_png_time(benchmark: &mut Benchmark, write_png_time: f64)
pub fn add_write_png_time(benchmark: &mut Benchmark, write_png_time: f64)
Adds time spent writing to the write time counter.