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) -> T
pub fn execute<F, T, H>(&mut self, update_fn: H, target_fn: F) -> T
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.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Benchmark
impl RefUnwindSafe for Benchmark
impl Send for Benchmark
impl Sync for Benchmark
impl Unpin for Benchmark
impl UnwindSafe for Benchmark
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more