| 1 | use criterionrust-analyzer cargo criterion 0.5.1 crate/::{black_boxrust-analyzer cargo criterion 0.5.1 black_box()., criterion_grouprust-analyzer cargo criterion 0.5.1 macros/criterion_group!, criterion_mainrust-analyzer cargo criterion 0.5.1 macros/criterion_main!, BenchmarkIdrust-analyzer cargo criterion 0.5.1 benchmark_group/BenchmarkId#, Criterionrust-analyzer cargo criterion 0.5.1 Criterion#}; |
| 2 | |
| 3 | fn size_benchmarksrust-analyzer cargo imagesize 0.13.0 size_benchmarks().(c: &mut Criterionrust-analyzer cargo criterion 0.5.1 Criterion#) { |
| 4 | let mut group = c.benchmark_grouprust-analyzer cargo criterion 0.5.1 impl#[`Criterion<M>`]benchmark_group().("imagesize"); |
| 5 | |
| 6 | let mut paths = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().(); |
| 7 | for file in walkdirrust-analyzer cargo walkdir 2.5.0 crate/::WalkDirrust-analyzer cargo walkdir 2.5.0 WalkDir#::newrust-analyzer cargo walkdir 2.5.0 impl#[WalkDir]new().("tests/images") |
| 8 | .into_iterrust-analyzer cargo walkdir 2.5.0 impl#[WalkDir][IntoIterator]into_iter().() |
| 9 | .filter_maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#filter_map().(|file| file.okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]ok().()) |
| 10 | { |
| 11 | if file.metadatarust-analyzer cargo walkdir 2.5.0 dent/impl#[DirEntry]metadata().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().().is_filerust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/impl#[Metadata]is_file().() { |
| 12 | paths.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/::canonicalizerust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/canonicalize().(file.pathrust-analyzer cargo walkdir 2.5.0 dent/impl#[DirEntry]path().()).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().()); |
| 13 | } |
| 14 | } |
| 15 | |
| 16 | group.bench_with_inputrust-analyzer cargo criterion 0.5.1 benchmark_group/impl#[`BenchmarkGroup<'a, M>`]bench_with_input().( |
| 17 | BenchmarkIdrust-analyzer cargo criterion 0.5.1 benchmark_group/BenchmarkId#::from_parameterrust-analyzer cargo criterion 0.5.1 benchmark_group/impl#[BenchmarkId]from_parameter().(paths.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().()), |
| 18 | &paths, |
| 19 | |b, paths| { |
| 20 | b.iterrust-analyzer cargo criterion 0.5.1 bencher/impl#[`Bencher<'a, M>`]iter().(|| { |
| 21 | for path in paths { |
| 22 | let _ = imagesizerust-analyzer cargo imagesize 0.13.0 crate/::sizerust-analyzer cargo imagesize 0.13.0 size().(black_boxrust-analyzer cargo criterion 0.5.1 black_box().(path)); |
| 23 | } |
| 24 | }) |
| 25 | }, |
| 26 | ); |
| 27 | |
| 28 | group.finishrust-analyzer cargo criterion 0.5.1 benchmark_group/impl#[`BenchmarkGroup<'a, M>`]finish().(); |
| 29 | } |
| 30 | |
| 31 | criterion_grouprust-analyzer cargo criterion 0.5.1 macros/criterion_group!!(benchesrust-analyzer cargo imagesize 0.13.0 benches()., size_benchmarksrust-analyzer cargo imagesize 0.13.0 size_benchmarks().); |
| 32 | criterion_mainrust-analyzer cargo criterion 0.5.1 macros/criterion_main!!(benchesrust-analyzer cargo imagesize 0.13.0 benches().); |