mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Add a benchmark for for unmultiply_inplace
in pixels
(#33584)
* bench unmultiply_inplace Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> * create data in one line Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> * number_of_pixels Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> --------- Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
This commit is contained in:
parent
58f34ad7a3
commit
1ddfde96ce
3 changed files with 189 additions and 0 deletions
30
components/pixels/benches.rs
Normal file
30
components/pixels/benches.rs
Normal file
|
@ -0,0 +1,30 @@
|
|||
/* 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(&mut data),
|
||||
BatchSize::SmallInput,
|
||||
)
|
||||
});
|
||||
}
|
||||
|
||||
criterion_group!(benches, bench);
|
||||
criterion_main!(benches);
|
Loading…
Add table
Add a link
Reference in a new issue