servo/components/pixels/benches.rs
Euclid Ye 0de6d1bc3a
Update pixels::unmultiply_inplace to support RB swap and use it in canvas_state (#35313)
* update unmultiply_inplace to handle reversed RGB

Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>

* Reuse unmultiply_inplace instead of manual compute; remove unused

Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>

---------

Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
2025-02-06 05:02:49 +00:00

30 lines
803 B
Rust

/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use criterion::*;
fn create_data(number_of_pixels: usize) -> Vec<u8> {
(0..=number_of_pixels)
.map(|i| {
let i = (i % 255) as u8;
[i, i, i, i]
})
.flatten()
.collect()
}
fn bench(c: &mut Criterion) {
let data = create_data(1_000_000);
c.bench_function("unmultiply_inplace", move |b| {
b.iter_batched(
|| data.clone(),
|mut data| pixels::unmultiply_inplace::<false>(&mut data),
BatchSize::SmallInput,
)
});
}
criterion_group!(benches, bench);
criterion_main!(benches);