| 1 | use binary_mergerust-analyzer cargo binary-merge 0.1.2 crate/::{MergeOperationrust-analyzer cargo binary-merge 0.1.2 MergeOperation#, MergeStaterust-analyzer cargo binary-merge 0.1.2 MergeState#}; |
| 2 | use criterionrust-analyzer cargo criterion 0.3.6 crate/::{black_boxrust-analyzer cargo criterion 0.3.6 black_box()., criterion_grouprust-analyzer cargo criterion 0.3.6 macros/criterion_group!, criterion_mainrust-analyzer cargo criterion 0.3.6 macros/criterion_main!, Criterionrust-analyzer cargo criterion 0.3.6 Criterion#}; |
| 3 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::{anyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core any/::type_namerust-analyzer cargo core https://github.com/rust-lang/rust/library/core any/type_name()., opsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/::Rangerust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#, rcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc rc/::Rcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc rc/Rc#}; |
| 4 | |
| 5 | struct VecMergeStaterust-analyzer cargo binary-merge 0.1.2 VecMergeState#<'a, T> { |
| 6 | arust-analyzer cargo binary-merge 0.1.2 VecMergeState#a.: stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::slicerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc slice/::Iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/Iter#<'a, T>, |
| 7 | brust-analyzer cargo binary-merge 0.1.2 VecMergeState#b.: stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::slicerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc slice/::Iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/Iter#<'a, T>, |
| 8 | rrust-analyzer cargo binary-merge 0.1.2 VecMergeState#r.: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<T>, |
| 9 | } |
| 10 | |
| 11 | impl<'a, T> MergeStaterust-analyzer cargo binary-merge 0.1.2 MergeState# for VecMergeStaterust-analyzer cargo binary-merge 0.1.2 VecMergeState#<'a, T> { |
| 12 | type Arust-analyzer cargo binary-merge 0.1.2 impl#[`VecMergeState<'a, T>`][MergeState]A# = T; |
| 13 | |
| 14 | type Brust-analyzer cargo binary-merge 0.1.2 impl#[`VecMergeState<'a, T>`][MergeState]B# = T; |
| 15 | |
| 16 | fn a_slicerust-analyzer cargo binary-merge 0.1.2 impl#[`VecMergeState<'a, T>`][MergeState]a_slice().(&self) -> &[Selfrust-analyzer cargo binary-merge 0.1.2 impl#[`VecMergeState<'a, T>`][MergeState]::Arust-analyzer cargo binary-merge 0.1.2 MergeState#A#] { |
| 17 | self.arust-analyzer cargo binary-merge 0.1.2 VecMergeState#a..as_slicerust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/impl#[`Iter<'a, T>`]as_slice().() |
| 18 | } |
| 19 | |
| 20 | fn b_slicerust-analyzer cargo binary-merge 0.1.2 impl#[`VecMergeState<'a, T>`][MergeState]b_slice().(&self) -> &[Selfrust-analyzer cargo binary-merge 0.1.2 impl#[`VecMergeState<'a, T>`][MergeState]::Brust-analyzer cargo binary-merge 0.1.2 MergeState#B#] { |
| 21 | self.brust-analyzer cargo binary-merge 0.1.2 VecMergeState#b..as_slicerust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/impl#[`Iter<'a, T>`]as_slice().() |
| 22 | } |
| 23 | } |
| 24 | |
| 25 | struct BinaryMergeUnionrust-analyzer cargo binary-merge 0.1.2 BinaryMergeUnion#; |
| 26 | |
| 27 | impl<'a, T: Ordrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord# + Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#> MergeOperationrust-analyzer cargo binary-merge 0.1.2 MergeOperation#<VecMergeStaterust-analyzer cargo binary-merge 0.1.2 VecMergeState#<'a, T>> for BinaryMergeUnionrust-analyzer cargo binary-merge 0.1.2 BinaryMergeUnion# { |
| 28 | fn from_arust-analyzer cargo binary-merge 0.1.2 impl#[BinaryMergeUnion][`MergeOperation<VecMergeState<'a, T>>`]from_a().(&self, m: &mut VecMergeStaterust-analyzer cargo binary-merge 0.1.2 VecMergeState#<'a, T>, n: usize) -> bool { |
| 29 | m.rrust-analyzer cargo binary-merge 0.1.2 VecMergeState#r..extendrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Extend<T>`]extend().((&mut m.arust-analyzer cargo binary-merge 0.1.2 VecMergeState#a.).clonedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#cloned().().takerust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#take().(n)); |
| 30 | true |
| 31 | } |
| 32 | |
| 33 | fn from_brust-analyzer cargo binary-merge 0.1.2 impl#[BinaryMergeUnion][`MergeOperation<VecMergeState<'a, T>>`]from_b().(&self, m: &mut VecMergeStaterust-analyzer cargo binary-merge 0.1.2 VecMergeState#<'a, T>, n: usize) -> bool { |
| 34 | m.rrust-analyzer cargo binary-merge 0.1.2 VecMergeState#r..extendrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Extend<T>`]extend().((&mut m.brust-analyzer cargo binary-merge 0.1.2 VecMergeState#b.).clonedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#cloned().().takerust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#take().(n)); |
| 35 | true |
| 36 | } |
| 37 | |
| 38 | fn collisionrust-analyzer cargo binary-merge 0.1.2 impl#[BinaryMergeUnion][`MergeOperation<VecMergeState<'a, T>>`]collision().(&self, m: &mut VecMergeStaterust-analyzer cargo binary-merge 0.1.2 VecMergeState#<'a, T>) -> bool { |
| 39 | m.rrust-analyzer cargo binary-merge 0.1.2 VecMergeState#r..extendrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Extend<T>`]extend().((&mut m.arust-analyzer cargo binary-merge 0.1.2 VecMergeState#a.).clonedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#cloned().().takerust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#take().(1)); |
| 40 | m.brust-analyzer cargo binary-merge 0.1.2 VecMergeState#b..nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/impl#[`Iter<'a, T>`][Iterator]next().(); |
| 41 | true |
| 42 | } |
| 43 | |
| 44 | fn cmprust-analyzer cargo binary-merge 0.1.2 impl#[BinaryMergeUnion][`MergeOperation<VecMergeState<'a, T>>`]cmp().(&self, a: &T, b: &T) -> stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::cmprust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/::Orderingrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ordering# { |
| 45 | a.cmprust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord#cmp().(b) |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | struct TapeMergeUnionrust-analyzer cargo binary-merge 0.1.2 TapeMergeUnion#; |
| 50 | |
| 51 | impl<'a, T: Ordrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord# + Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#> MergeOperationrust-analyzer cargo binary-merge 0.1.2 MergeOperation#<VecMergeStaterust-analyzer cargo binary-merge 0.1.2 VecMergeState#<'a, T>> for TapeMergeUnionrust-analyzer cargo binary-merge 0.1.2 TapeMergeUnion# { |
| 52 | fn from_arust-analyzer cargo binary-merge 0.1.2 impl#[TapeMergeUnion][`MergeOperation<VecMergeState<'a, T>>`]from_a().(&self, m: &mut VecMergeStaterust-analyzer cargo binary-merge 0.1.2 VecMergeState#<'a, T>, n: usize) -> bool { |
| 53 | m.rrust-analyzer cargo binary-merge 0.1.2 VecMergeState#r..extendrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Extend<T>`]extend().((&mut m.arust-analyzer cargo binary-merge 0.1.2 VecMergeState#a.).clonedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#cloned().().takerust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#take().(n)); |
| 54 | true |
| 55 | } |
| 56 | |
| 57 | fn from_brust-analyzer cargo binary-merge 0.1.2 impl#[TapeMergeUnion][`MergeOperation<VecMergeState<'a, T>>`]from_b().(&self, m: &mut VecMergeStaterust-analyzer cargo binary-merge 0.1.2 VecMergeState#<'a, T>, n: usize) -> bool { |
| 58 | m.rrust-analyzer cargo binary-merge 0.1.2 VecMergeState#r..extendrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Extend<T>`]extend().((&mut m.brust-analyzer cargo binary-merge 0.1.2 VecMergeState#b.).clonedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#cloned().().takerust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#take().(n)); |
| 59 | true |
| 60 | } |
| 61 | |
| 62 | fn collisionrust-analyzer cargo binary-merge 0.1.2 impl#[TapeMergeUnion][`MergeOperation<VecMergeState<'a, T>>`]collision().(&self, m: &mut VecMergeStaterust-analyzer cargo binary-merge 0.1.2 VecMergeState#<'a, T>) -> bool { |
| 63 | m.rrust-analyzer cargo binary-merge 0.1.2 VecMergeState#r..extendrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Extend<T>`]extend().((&mut m.arust-analyzer cargo binary-merge 0.1.2 VecMergeState#a.).clonedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#cloned().().takerust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#take().(1)); |
| 64 | m.brust-analyzer cargo binary-merge 0.1.2 VecMergeState#b..nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/impl#[`Iter<'a, T>`][Iterator]next().(); |
| 65 | true |
| 66 | } |
| 67 | |
| 68 | fn cmprust-analyzer cargo binary-merge 0.1.2 impl#[TapeMergeUnion][`MergeOperation<VecMergeState<'a, T>>`]cmp().(&self, a: &T, b: &T) -> stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::cmprust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/::Orderingrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ordering# { |
| 69 | a.cmprust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord#cmp().(b) |
| 70 | } |
| 71 | |
| 72 | const MCM_THRESHOLDrust-analyzer cargo binary-merge 0.1.2 impl#[TapeMergeUnion][`MergeOperation<VecMergeState<'a, T>>`]MCM_THRESHOLD.: usize = usize::MAXrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[usize]MAX.; |
| 73 | } |
| 74 | |
| 75 | /// binary merge union |
| 76 | fn binary_merge_unionrust-analyzer cargo binary-merge 0.1.2 binary_merge_union().<T: Ordrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord# + Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#>(a: &[T], b: &[T]) -> Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<T> { |
| 77 | let mut state = VecMergeStaterust-analyzer cargo binary-merge 0.1.2 VecMergeState# { |
| 78 | arust-analyzer cargo binary-merge 0.1.2 VecMergeState#a.: a.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().(), |
| 79 | brust-analyzer cargo binary-merge 0.1.2 VecMergeState#b.: b.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().(), |
| 80 | rrust-analyzer cargo binary-merge 0.1.2 VecMergeState#r.: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::with_capacityrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]with_capacity().(a.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().().maxrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord#max().(b.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().())), |
| 81 | }; |
| 82 | BinaryMergeUnionrust-analyzer cargo binary-merge 0.1.2 BinaryMergeUnion#.mergerust-analyzer cargo binary-merge 0.1.2 MergeOperation#merge().(&mut state); |
| 83 | state.rrust-analyzer cargo binary-merge 0.1.2 VecMergeState#r. |
| 84 | } |
| 85 | |
| 86 | /// tape merge union |
| 87 | fn tape_merge_unionrust-analyzer cargo binary-merge 0.1.2 tape_merge_union().<T: Ordrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord# + Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#>(a: &[T], b: &[T]) -> Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<T> { |
| 88 | let mut state = VecMergeStaterust-analyzer cargo binary-merge 0.1.2 VecMergeState# { |
| 89 | arust-analyzer cargo binary-merge 0.1.2 VecMergeState#a.: a.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().(), |
| 90 | brust-analyzer cargo binary-merge 0.1.2 VecMergeState#b.: b.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().(), |
| 91 | rrust-analyzer cargo binary-merge 0.1.2 VecMergeState#r.: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::with_capacityrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]with_capacity().(a.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().().maxrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord#max().(b.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().())), |
| 92 | }; |
| 93 | TapeMergeUnionrust-analyzer cargo binary-merge 0.1.2 TapeMergeUnion#.mergerust-analyzer cargo binary-merge 0.1.2 MergeOperation#merge().(&mut state); |
| 94 | state.rrust-analyzer cargo binary-merge 0.1.2 VecMergeState#r. |
| 95 | } |
| 96 | |
| 97 | /// handrolled version of a tape merge, just as a baseline |
| 98 | fn tape_merge_union_handrolledrust-analyzer cargo binary-merge 0.1.2 tape_merge_union_handrolled().<T: Ordrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord# + Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#>(a: &[T], b: &[T]) -> Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<T> { |
| 99 | let mut res = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::with_capacityrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]with_capacity().(a.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().().maxrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord#max().(b.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().())); |
| 100 | let mut ai = 0; |
| 101 | let mut bi = 0; |
| 102 | while ai rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().a.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() && bi rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().b.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() { |
| 103 | match a[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().ai]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..cmprust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord#cmp().(&b[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().bi]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().) { |
| 104 | stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::cmprust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/::Orderingrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ordering#::Lessrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ordering#Less# => { |
| 105 | res.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(a[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().ai]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().()); |
| 106 | ai rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().1; |
| 107 | } |
| 108 | stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::cmprust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/::Orderingrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ordering#::Equalrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ordering#Equal# => { |
| 109 | res.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(a[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().ai]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().()); |
| 110 | ai rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().1; |
| 111 | bi rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().1; |
| 112 | } |
| 113 | stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::cmprust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/::Orderingrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ordering#::Greaterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ordering#Greater# => { |
| 114 | res.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(b[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().bi]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().()); |
| 115 | bi rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().1; |
| 116 | } |
| 117 | } |
| 118 | } |
| 119 | res.extend_from_slicerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]extend_from_slice().(&a[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().ai..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFrom#]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().); |
| 120 | res.extend_from_slicerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]extend_from_slice().(&b[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().bi..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFrom#]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().); |
| 121 | res |
| 122 | } |
| 123 | |
| 124 | fn union_benchesrust-analyzer cargo binary-merge 0.1.2 union_benches().<T: Ordrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord# + Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#>( |
| 125 | a: Rangerust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#<usize>, |
| 126 | b: Rangerust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#<usize>, |
| 127 | f: impl Fnrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/function/Fn#(usize) -> T + Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy#, |
| 128 | name: &str, |
| 129 | c: &mut Criterionrust-analyzer cargo criterion 0.3.6 Criterion#, |
| 130 | ) { |
| 131 | let name = formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{} T={} a={:?} b={:?}", name, type_namerust-analyzer cargo core https://github.com/rust-lang/rust/library/core any/type_name().::<T>(), a, b); |
| 132 | let ae = a.maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(f).collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_>>(); |
| 133 | let be = b.maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(f).collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_>>(); |
| 134 | c.bench_functionrust-analyzer cargo criterion 0.3.6 impl#[`Criterion<M>`]bench_function().(&formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("union {} binary merge", name), |bencher| { |
| 135 | bencher.iterrust-analyzer cargo criterion 0.3.6 bencher/impl#[`Bencher<'a, M>`]iter().(|| binary_merge_unionrust-analyzer cargo binary-merge 0.1.2 binary_merge_union().(black_boxrust-analyzer cargo criterion 0.3.6 black_box().(&ae), black_boxrust-analyzer cargo criterion 0.3.6 black_box().(&be))) |
| 136 | }); |
| 137 | c.bench_functionrust-analyzer cargo criterion 0.3.6 impl#[`Criterion<M>`]bench_function().(&formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("union {} tape merge", name), |bencher| { |
| 138 | bencher.iterrust-analyzer cargo criterion 0.3.6 bencher/impl#[`Bencher<'a, M>`]iter().(|| tape_merge_unionrust-analyzer cargo binary-merge 0.1.2 tape_merge_union().(black_boxrust-analyzer cargo criterion 0.3.6 black_box().(&ae), black_boxrust-analyzer cargo criterion 0.3.6 black_box().(&be))) |
| 139 | }); |
| 140 | c.bench_functionrust-analyzer cargo criterion 0.3.6 impl#[`Criterion<M>`]bench_function().( |
| 141 | &formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("union {} tape merge, handrolled", name), |
| 142 | |bencher| bencher.iterrust-analyzer cargo criterion 0.3.6 bencher/impl#[`Bencher<'a, M>`]iter().(|| tape_merge_union_handrolledrust-analyzer cargo binary-merge 0.1.2 tape_merge_union_handrolled().(black_boxrust-analyzer cargo criterion 0.3.6 black_box().(&ae), black_boxrust-analyzer cargo criterion 0.3.6 black_box().(&be))), |
| 143 | ); |
| 144 | } |
| 145 | |
| 146 | fn full_overlaprust-analyzer cargo binary-merge 0.1.2 full_overlap().(c: &mut Criterionrust-analyzer cargo criterion 0.3.6 Criterion#) { |
| 147 | union_benchesrust-analyzer cargo binary-merge 0.1.2 union_benches().(0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#1000, 0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#1000, |x| x, "full_overlap", c); |
| 148 | } |
| 149 | |
| 150 | fn partial_overlaprust-analyzer cargo binary-merge 0.1.2 partial_overlap().(c: &mut Criterionrust-analyzer cargo criterion 0.3.6 Criterion#) { |
| 151 | union_benchesrust-analyzer cargo binary-merge 0.1.2 union_benches().(0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#1000, 500..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#1500, |x| x, "partial_overlap", c); |
| 152 | } |
| 153 | |
| 154 | fn no_overlaprust-analyzer cargo binary-merge 0.1.2 no_overlap().(c: &mut Criterionrust-analyzer cargo criterion 0.3.6 Criterion#) { |
| 155 | union_benchesrust-analyzer cargo binary-merge 0.1.2 union_benches().(0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#1000, 1000..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#2000, |x| x, "no_overlap", c); |
| 156 | } |
| 157 | |
| 158 | fn insertionrust-analyzer cargo binary-merge 0.1.2 insertion().(c: &mut Criterionrust-analyzer cargo criterion 0.3.6 Criterion#) { |
| 159 | union_benchesrust-analyzer cargo binary-merge 0.1.2 union_benches().(0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#2000, 232..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#233, |x| x, "insert", c); |
| 160 | } |
| 161 | |
| 162 | fn insertion_rev_0rust-analyzer cargo binary-merge 0.1.2 insertion_rev_0().<T: Ordrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord# + Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#>(f: impl Fnrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/function/Fn#(usize) -> T + Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy#, c: &mut Criterionrust-analyzer cargo criterion 0.3.6 Criterion#) { |
| 163 | union_benchesrust-analyzer cargo binary-merge 0.1.2 union_benches().(1234..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#1235, 0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#2000, f, "insert", c); |
| 164 | } |
| 165 | |
| 166 | fn insertion_rev_usizerust-analyzer cargo binary-merge 0.1.2 insertion_rev_usize().(c: &mut Criterionrust-analyzer cargo criterion 0.3.6 Criterion#) { |
| 167 | insertion_rev_0rust-analyzer cargo binary-merge 0.1.2 insertion_rev_0().(|x| x, c) |
| 168 | } |
| 169 | |
| 170 | fn insertion_rev_ratiorust-analyzer cargo binary-merge 0.1.2 insertion_rev_ratio().(c: &mut Criterionrust-analyzer cargo criterion 0.3.6 Criterion#) { |
| 171 | insertion_rev_0rust-analyzer cargo binary-merge 0.1.2 insertion_rev_0().( |
| 172 | |x| { |
| 173 | // make a thing that is cheap to copy, but expensive to compare |
| 174 | let mut data = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![0u8; 4096 -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). 8]; |
| 175 | data.extend_from_slicerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]extend_from_slice().(&(x as u64).to_be_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u64]to_be_bytes().()); |
| 176 | Rcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc rc/Rc#::<[u8]>::fromrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc rc/impl#[`Rc<[T], A>`][`From<Vec<T, A>>`]from().(data) |
| 177 | }, |
| 178 | c, |
| 179 | ) |
| 180 | } |
| 181 | |
| 182 | criterion_grouprust-analyzer cargo criterion 0.3.6 macros/criterion_group!!( |
| 183 | benchesrust-analyzer cargo binary-merge 0.1.2 benches()., |
| 184 | full_overlaprust-analyzer cargo binary-merge 0.1.2 full_overlap()., |
| 185 | partial_overlaprust-analyzer cargo binary-merge 0.1.2 partial_overlap()., |
| 186 | no_overlaprust-analyzer cargo binary-merge 0.1.2 no_overlap()., |
| 187 | insertionrust-analyzer cargo binary-merge 0.1.2 insertion()., |
| 188 | insertion_rev_usizerust-analyzer cargo binary-merge 0.1.2 insertion_rev_usize()., |
| 189 | insertion_rev_ratiorust-analyzer cargo binary-merge 0.1.2 insertion_rev_ratio()., |
| 190 | ); |
| 191 | criterion_mainrust-analyzer cargo criterion 0.3.6 macros/criterion_main!!(benchesrust-analyzer cargo binary-merge 0.1.2 benches().); |