| 1 | #[macro_use] |
| 2 | extern crate criterionrust-analyzer cargo typed-arena 2.0.2 criterion/; |
| 3 | extern crate typed_arenarust-analyzer cargo typed-arena 2.0.2 typed_arena/; |
| 4 | |
| 5 | use criterionrust-analyzer cargo criterion 0.5.1 crate/::{BenchmarkIdrust-analyzer cargo criterion 0.5.1 benchmark_group/BenchmarkId#, Criterionrust-analyzer cargo criterion 0.5.1 Criterion#}; |
| 6 | |
| 7 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default:)] |
| 8 | struct Smallrust-analyzer cargo typed-arena 2.0.2 Small#(usize); |
| 9 | |
| 10 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default:)] |
| 11 | struct Bigrust-analyzer cargo typed-arena 2.0.2 Big#([usize; 32]); |
| 12 | |
| 13 | fn allocaterust-analyzer cargo typed-arena 2.0.2 allocate().<T: Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default#>(n: usize) { |
| 14 | let arena = typed_arenarust-analyzer cargo typed-arena 2.0.2 crate/::Arenarust-analyzer cargo typed-arena 2.0.2 Arena#::newrust-analyzer cargo typed-arena 2.0.2 impl#[`Arena<T>`]new().(); |
| 15 | for _ in 0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#n { |
| 16 | let val: &mut T = arena.allocrust-analyzer cargo typed-arena 2.0.2 impl#[`Arena<T>`]alloc().(Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default#::defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default#default().()); |
| 17 | criterionrust-analyzer cargo criterion 0.5.1 crate/::black_boxrust-analyzer cargo criterion 0.5.1 black_box().(val); |
| 18 | } |
| 19 | } |
| 20 | |
| 21 | fn criterion_benchmarkrust-analyzer cargo typed-arena 2.0.2 criterion_benchmark().(c: &mut Criterionrust-analyzer cargo criterion 0.5.1 Criterion#) { |
| 22 | let mut group = c.benchmark_grouprust-analyzer cargo criterion 0.5.1 impl#[`Criterion<M>`]benchmark_group().("allocate"); |
| 23 | for n in 1..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#5 { |
| 24 | let n = n rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().1000; |
| 25 | group.throughputrust-analyzer cargo criterion 0.5.1 benchmark_group/impl#[`BenchmarkGroup<'a, M>`]throughput().(criterionrust-analyzer cargo criterion 0.5.1 crate/::Throughputrust-analyzer cargo criterion 0.5.1 Throughput#::Elementsrust-analyzer cargo criterion 0.5.1 Throughput#Elements#(n as u64)); |
| 26 | group.bench_with_inputrust-analyzer cargo criterion 0.5.1 benchmark_group/impl#[`BenchmarkGroup<'a, M>`]bench_with_input().(BenchmarkIdrust-analyzer cargo criterion 0.5.1 benchmark_group/BenchmarkId#::newrust-analyzer cargo criterion 0.5.1 benchmark_group/impl#[BenchmarkId]new().("allocate-small", n), &n, |b, &n| { |
| 27 | b.iterrust-analyzer cargo criterion 0.5.1 bencher/impl#[`Bencher<'a, M>`]iter().(|| allocaterust-analyzer cargo typed-arena 2.0.2 allocate().::<Smallrust-analyzer cargo typed-arena 2.0.2 Small#>(n)) |
| 28 | }); |
| 29 | group.bench_with_inputrust-analyzer cargo criterion 0.5.1 benchmark_group/impl#[`BenchmarkGroup<'a, M>`]bench_with_input().(BenchmarkIdrust-analyzer cargo criterion 0.5.1 benchmark_group/BenchmarkId#::newrust-analyzer cargo criterion 0.5.1 benchmark_group/impl#[BenchmarkId]new().("allocate-big", n), &n, |b, &n| { |
| 30 | b.iterrust-analyzer cargo criterion 0.5.1 bencher/impl#[`Bencher<'a, M>`]iter().(|| allocaterust-analyzer cargo typed-arena 2.0.2 allocate().::<Bigrust-analyzer cargo typed-arena 2.0.2 Big#>(n)) |
| 31 | }); |
| 32 | } |
| 33 | } |
| 34 | |
| 35 | criterion_grouprust-analyzer cargo criterion 0.5.1 macros/criterion_group!!(benchesrust-analyzer cargo typed-arena 2.0.2 benches()., criterion_benchmarkrust-analyzer cargo typed-arena 2.0.2 criterion_benchmark().); |
| 36 | criterion_mainrust-analyzer cargo criterion 0.5.1 macros/criterion_main!!(benchesrust-analyzer cargo typed-arena 2.0.2 benches().); |