Skip to content
This repository was archived by the owner on Apr 13, 2026. It is now read-only.

Commit 8dc0f05

Browse files
committed
fix(bench): unify type usage in vlan_generation.rs and csv_operations.rs
- Update ci_or_local calls to use u16 and usize literals for consistency across benchmarks - Adjusted count handling in benchmark functions to avoid type mismatches - Ensures compatibility with generate_vlan_configurations and maintains CI-optimized dataset sizes - All benchmarks executed successfully with no errors
1 parent ad0652d commit 8dc0f05

2 files changed

Lines changed: 11 additions & 11 deletions

File tree

benches/csv_operations.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,20 +46,20 @@ fn bench_csv_deserialization(c: &mut Criterion) {
4646

4747
// Use CI-appropriate dataset sizes for CSV operations
4848
let counts = ci_or_local(&[100u16, 500u16], &[100u16, 500u16, 1000u16, 2000u16]);
49-
for count in counts.iter() {
50-
let configs = generate_vlan_configurations(*count, Some(42), None).unwrap();
49+
for count in counts.iter().copied().map(|c| c as usize) {
50+
let configs = generate_vlan_configurations(count as u16, Some(42), None).unwrap();
5151
let temp_file = NamedTempFile::new().unwrap();
5252
write_csv(&configs, temp_file.path()).unwrap();
5353

54-
group.bench_with_input(BenchmarkId::new("read_csv", count), count, |b, _| {
54+
group.bench_with_input(BenchmarkId::new("read_csv", count), &count, |b, _| {
5555
b.iter(|| {
5656
read_csv(black_box(temp_file.path())).unwrap();
5757
})
5858
});
5959

6060
group.bench_with_input(
6161
BenchmarkId::new("read_csv_streaming", count),
62-
count,
62+
&count,
6363
|b, _| {
6464
b.iter(|| {
6565
let mut counter = 0;
@@ -81,10 +81,10 @@ fn bench_csv_round_trip(c: &mut Criterion) {
8181

8282
// Use CI-appropriate dataset sizes for round-trip tests
8383
let counts = ci_or_local(&[100u16, 500u16], &[100u16, 500u16, 1000u16]);
84-
for count in counts.iter() {
85-
let configs = generate_vlan_configurations(*count, Some(42), None).unwrap();
84+
for count in counts.iter().copied().map(|c| c as usize) {
85+
let configs = generate_vlan_configurations(count as u16, Some(42), None).unwrap();
8686

87-
group.bench_with_input(BenchmarkId::new("round_trip", count), count, |b, _| {
87+
group.bench_with_input(BenchmarkId::new("round_trip", count), &count, |b, _| {
8888
b.iter(|| {
8989
let temp_file = NamedTempFile::new().unwrap();
9090
write_csv(black_box(&configs), temp_file.path()).unwrap();
@@ -94,7 +94,7 @@ fn bench_csv_round_trip(c: &mut Criterion) {
9494

9595
group.bench_with_input(
9696
BenchmarkId::new("round_trip_streaming", count),
97-
count,
97+
&count,
9898
|b, _| {
9999
b.iter(|| {
100100
let temp_file = NamedTempFile::new().unwrap();

benches/vlan_generation.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use std::hint::black_box;
88

99
fn bench_vlan_generation(c: &mut Criterion) {
1010
// Use CI-appropriate dataset sizes
11-
let sizes = ci_or_local(&[10, 100], &[10, 100, 1000]);
11+
let sizes = ci_or_local(&[10u16, 100u16], &[10u16, 100u16, 1000u16]);
1212

1313
for &size in &sizes {
1414
c.bench_function(&format!("generate_{}_vlans", size), |b| {
@@ -34,7 +34,7 @@ fn bench_vlan_generation(c: &mut Criterion) {
3434
}
3535

3636
// RFC 1918 validation benchmarks with CI-appropriate size
37-
let validation_size = ci_or_local(&[50], &[100])[0];
37+
let validation_size = ci_or_local(&[50usize], &[100usize])[0];
3838
c.bench_function(&format!("rfc1918_validation_{}", validation_size), |b| {
3939
let mut generator = VlanGenerator::new(Some(42));
4040
let configs = generator.generate_batch(validation_size).unwrap();
@@ -47,7 +47,7 @@ fn bench_vlan_generation(c: &mut Criterion) {
4747
});
4848

4949
// Memory efficiency test for large batches (within VLAN ID limits)
50-
let memory_test_size = ci_or_local(&[1000], &[3000])[0];
50+
let memory_test_size = ci_or_local(&[1000usize], &[3000usize])[0];
5151
c.bench_function(
5252
&format!("generate_{}_vlans_memory_test", memory_test_size),
5353
|b| {

0 commit comments

Comments
 (0)