This is an automated email from the ASF dual-hosted git repository. pmcgleenon pushed a commit to branch countmin-minimal in repository https://gitbox.apache.org/repos/asf/datasketches-rust.git
commit 3c275134c92b2fbc7e4eb2c9b88d52bbda1c4492 Author: Patrick McGleenon <[email protected]> AuthorDate: Wed Oct 21 20:58:23 2026 +0100 bench(countmin): add estimate benchmarks --- benchmarks/countmin/estimate.rs | 58 +++++++++++++++++++++++++++++++++++++++++ benchmarks/countmin/mod.rs | 1 + 2 files changed, 59 insertions(+) diff --git a/benchmarks/countmin/estimate.rs b/benchmarks/countmin/estimate.rs new file mode 100644 index 0000000..4a2777f --- /dev/null +++ b/benchmarks/countmin/estimate.rs @@ -0,0 +1,58 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +use datasketches::countmin::CountMinSketch; +use datasketches::hash::value::raw_bytes; +use divan::Bencher; +use divan::black_box; +use divan::counter::ItemsCount; + +use crate::hash_inputs::ITEMS; +use crate::hash_inputs::bytes_32_values; + +#[divan::bench] +fn u64(bencher: Bencher) { + let mut sketch = CountMinSketch::<u64>::new(4, 16_384).unwrap(); + for value in 0..ITEMS as u64 { + sketch.update(value); + } + + bencher.counter(ItemsCount::new(ITEMS)).bench_local(|| { + let mut total = 0u64; + for value in 0..ITEMS as u64 { + total = total.wrapping_add(sketch.estimate(black_box(value))); + } + black_box(total) + }); +} + +#[divan::bench] +fn bytes_32(bencher: Bencher) { + let values = bytes_32_values(); + let mut sketch = CountMinSketch::<u64>::new(4, 16_384).unwrap(); + for value in &values { + sketch.update(raw_bytes::from_slice(value)); + } + + bencher.counter(ItemsCount::new(ITEMS)).bench_local(|| { + let mut total = 0u64; + for value in &values { + total = total.wrapping_add(sketch.estimate(raw_bytes::from_slice(black_box(value)))); + } + black_box(total) + }); +} diff --git a/benchmarks/countmin/mod.rs b/benchmarks/countmin/mod.rs index 375b6d8..39f1404 100644 --- a/benchmarks/countmin/mod.rs +++ b/benchmarks/countmin/mod.rs @@ -16,4 +16,5 @@ // under the License. mod decay; +mod estimate; mod update; --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
