This repository has been archived on 2026-08-31. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
donglora/vendor/hashbrown/benches/set_ops.rs
T
swaitsandClaude Opus 4.6 3102fc747a feat: add display UI with splash screen, dashboard, and RSSI sparkline
Implement full SSD1306 OLED display support:
- Splash screen on boot (1.5s) with project name, version, board
- Dashboard showing radio state, config, counters, RSSI/SNR
- RSSI history sparkline (64-sample ring buffer, 2px-wide bars)
- DisplayOn/DisplayOff host commands routed via dedicated channel
- Pure render functions against generic DrawTarget (no hardware coupling)
- Display on/off control bypasses radio task entirely

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-29 20:42:54 -06:00

149 lines
4.0 KiB
Rust

//! This file contains benchmarks for the ops traits implemented by HashSet.
//! Each test is intended to have a defined larger and smaller set,
//! but using a larger size for the "small" set works just as well.
//!
//! Each assigning test is done in the configuration that is faster. Cheating, I know.
//! The exception to this is Sub, because there the result differs. So I made two benchmarks for Sub.
#![feature(test)]
extern crate test;
use hashbrown::HashSet;
use test::Bencher;
/// The number of items to generate for the larger of the sets.
const LARGE_SET_SIZE: usize = 1000;
/// The number of items to generate for the smaller of the sets.
const SMALL_SET_SIZE: usize = 100;
/// The number of keys present in both sets.
const OVERLAP: usize =
[LARGE_SET_SIZE, SMALL_SET_SIZE][(LARGE_SET_SIZE < SMALL_SET_SIZE) as usize] / 2;
/// Creates a set containing end - start unique string elements.
fn create_set(start: usize, end: usize) -> HashSet<String> {
(start..end).map(|nr| format!("key{}", nr)).collect()
}
#[bench]
fn set_ops_bit_or(b: &mut Bencher) {
let large_set = create_set(0, LARGE_SET_SIZE);
let small_set = create_set(
LARGE_SET_SIZE - OVERLAP,
LARGE_SET_SIZE + SMALL_SET_SIZE - OVERLAP,
);
b.iter(|| &large_set | &small_set)
}
#[bench]
fn set_ops_bit_and(b: &mut Bencher) {
let large_set = create_set(0, LARGE_SET_SIZE);
let small_set = create_set(
LARGE_SET_SIZE - OVERLAP,
LARGE_SET_SIZE + SMALL_SET_SIZE - OVERLAP,
);
b.iter(|| &large_set & &small_set)
}
#[bench]
fn set_ops_bit_xor(b: &mut Bencher) {
let large_set = create_set(0, LARGE_SET_SIZE);
let small_set = create_set(
LARGE_SET_SIZE - OVERLAP,
LARGE_SET_SIZE + SMALL_SET_SIZE - OVERLAP,
);
b.iter(|| &large_set ^ &small_set)
}
#[bench]
fn set_ops_sub_large_small(b: &mut Bencher) {
let large_set = create_set(0, LARGE_SET_SIZE);
let small_set = create_set(
LARGE_SET_SIZE - OVERLAP,
LARGE_SET_SIZE + SMALL_SET_SIZE - OVERLAP,
);
b.iter(|| &large_set - &small_set)
}
#[bench]
fn set_ops_sub_small_large(b: &mut Bencher) {
let large_set = create_set(0, LARGE_SET_SIZE);
let small_set = create_set(
LARGE_SET_SIZE - OVERLAP,
LARGE_SET_SIZE + SMALL_SET_SIZE - OVERLAP,
);
b.iter(|| &small_set - &large_set)
}
#[bench]
fn set_ops_bit_or_assign(b: &mut Bencher) {
let large_set = create_set(0, LARGE_SET_SIZE);
let small_set = create_set(
LARGE_SET_SIZE - OVERLAP,
LARGE_SET_SIZE + SMALL_SET_SIZE - OVERLAP,
);
b.iter(|| {
let mut set = large_set.clone();
set |= &small_set;
set
});
}
#[bench]
fn set_ops_bit_and_assign(b: &mut Bencher) {
let large_set = create_set(0, LARGE_SET_SIZE);
let small_set = create_set(
LARGE_SET_SIZE - OVERLAP,
LARGE_SET_SIZE + SMALL_SET_SIZE - OVERLAP,
);
b.iter(|| {
let mut set = small_set.clone();
set &= &large_set;
set
});
}
#[bench]
fn set_ops_bit_xor_assign(b: &mut Bencher) {
let large_set = create_set(0, LARGE_SET_SIZE);
let small_set = create_set(
LARGE_SET_SIZE - OVERLAP,
LARGE_SET_SIZE + SMALL_SET_SIZE - OVERLAP,
);
b.iter(|| {
let mut set = large_set.clone();
set ^= &small_set;
set
});
}
#[bench]
fn set_ops_sub_assign_large_small(b: &mut Bencher) {
let large_set = create_set(0, LARGE_SET_SIZE);
let small_set = create_set(
LARGE_SET_SIZE - OVERLAP,
LARGE_SET_SIZE + SMALL_SET_SIZE - OVERLAP,
);
b.iter(|| {
let mut set = large_set.clone();
set -= &small_set;
set
});
}
#[bench]
fn set_ops_sub_assign_small_large(b: &mut Bencher) {
let large_set = create_set(0, LARGE_SET_SIZE);
let small_set = create_set(
LARGE_SET_SIZE - OVERLAP,
LARGE_SET_SIZE + SMALL_SET_SIZE - OVERLAP,
);
b.iter(|| {
let mut set = small_set.clone();
set -= &large_set;
set
});
}