Skip to content

Commit 2d9c804

Browse files
Copilotj143
andcommitted
style: apply cargo fmt to benchmarks and validation
Agent-Logs-Url: https://github.com/j143/6g/sessions/e3ba9647-691d-40e6-b612-cbf120088a1c Co-authored-by: j143 <53068787+j143@users.noreply.github.com>
1 parent da85597 commit 2d9c804

6 files changed

Lines changed: 61 additions & 77 deletions

File tree

crates/6g-core/benches/core_capacity.rs

Lines changed: 28 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,7 @@
88
99
use criterion::{black_box, criterion_group, criterion_main, BenchmarkId, Criterion, Throughput};
1010
use sixg_common::types::UeId;
11-
use sixg_core::{
12-
nssf::SliceType,
13-
smf::PduSessionType,
14-
CoreNetwork,
15-
};
11+
use sixg_core::{nssf::SliceType, smf::PduSessionType, CoreNetwork};
1612

1713
/// Benchmark UE registration burst throughput.
1814
///
@@ -22,22 +18,18 @@ fn bench_core_register_burst(c: &mut Criterion) {
2218

2319
for &n_ues in &[10usize, 50, 100, 250, 500, 1000] {
2420
group.throughput(Throughput::Elements(n_ues as u64));
25-
group.bench_with_input(
26-
BenchmarkId::new("ues", n_ues),
27-
&n_ues,
28-
|b, &n| {
29-
b.iter(|| {
30-
let mut core = CoreNetwork::new();
31-
let mut registered = 0usize;
32-
for i in 0..n {
33-
if core.register_ue(black_box(UeId(i as u64)), 1) {
34-
registered += 1;
35-
}
21+
group.bench_with_input(BenchmarkId::new("ues", n_ues), &n_ues, |b, &n| {
22+
b.iter(|| {
23+
let mut core = CoreNetwork::new();
24+
let mut registered = 0usize;
25+
for i in 0..n {
26+
if core.register_ue(black_box(UeId(i as u64)), 1) {
27+
registered += 1;
3628
}
37-
black_box(registered)
38-
})
39-
},
40-
);
29+
}
30+
black_box(registered)
31+
})
32+
});
4133
}
4234
group.finish();
4335
}
@@ -48,28 +40,24 @@ fn bench_session_establishment(c: &mut Criterion) {
4840

4941
for &n_ues in &[10usize, 50, 100] {
5042
group.throughput(Throughput::Elements(n_ues as u64));
51-
group.bench_with_input(
52-
BenchmarkId::new("ues", n_ues),
53-
&n_ues,
54-
|b, &n| {
55-
b.iter(|| {
56-
let mut core = CoreNetwork::new();
57-
let mut sessions = 0usize;
58-
for i in 0..n {
59-
let ue = UeId(i as u64);
60-
if core.register_ue(ue, 1) {
61-
if core
62-
.establish_session(ue, SliceType::EmBb, PduSessionType::Ip)
63-
.is_some()
64-
{
65-
sessions += 1;
66-
}
43+
group.bench_with_input(BenchmarkId::new("ues", n_ues), &n_ues, |b, &n| {
44+
b.iter(|| {
45+
let mut core = CoreNetwork::new();
46+
let mut sessions = 0usize;
47+
for i in 0..n {
48+
let ue = UeId(i as u64);
49+
if core.register_ue(ue, 1) {
50+
if core
51+
.establish_session(ue, SliceType::EmBb, PduSessionType::Ip)
52+
.is_some()
53+
{
54+
sessions += 1;
6755
}
6856
}
69-
black_box(sessions)
70-
})
71-
},
72-
);
57+
}
58+
black_box(sessions)
59+
})
60+
});
7361
}
7462
group.finish();
7563
}

crates/6g-mac/benches/mac_capacity.rs

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@ fn bench_scheduler_scale(c: &mut Criterion) {
2323
for &n_ues in &[8usize, 64, 128, 256, 512] {
2424
// Build channel states with varied SNR (linear 1..n_ues).
2525
let states: Vec<UeChannelState> = (0..n_ues)
26-
.map(|i| {
27-
UeChannelState::new(UeId(i as u64), SnrLinear::new(1.0 + i as f64 * 0.5))
28-
})
26+
.map(|i| UeChannelState::new(UeId(i as u64), SnrLinear::new(1.0 + i as f64 * 0.5)))
2927
.collect();
3028

3129
const TOTAL_RBS: usize = 273;
@@ -85,17 +83,19 @@ fn bench_harq_rounds_distribution(c: &mut Criterion) {
8583
let mut group = c.benchmark_group("harq_rounds_distribution");
8684

8785
// SNR linear values from −5 dB to 20 dB
88-
let snr_values: Vec<f64> = (-5..=20)
89-
.map(|db| 10f64.powf(db as f64 / 10.0))
90-
.collect();
86+
let snr_values: Vec<f64> = (-5..=20).map(|db| 10f64.powf(db as f64 / 10.0)).collect();
9187

9288
const N_SAMPLES: usize = 10_000;
9389

9490
group.throughput(Throughput::Elements(N_SAMPLES as u64));
9591
group.bench_function("chase_combining_10k_samples", |b| {
9692
b.iter(|| {
9793
let mut rounds_total = 0u64;
98-
for (i, &snr) in snr_values.iter().enumerate().take(N_SAMPLES % snr_values.len() + 1) {
94+
for (i, &snr) in snr_values
95+
.iter()
96+
.enumerate()
97+
.take(N_SAMPLES % snr_values.len() + 1)
98+
{
9999
let mut buf = ChaseCombineBuffer::default();
100100
let mut rounds = 0u8;
101101
while !buf.can_decode() && rounds < 8 {
@@ -117,13 +117,9 @@ fn bench_jain_fairness(c: &mut Criterion) {
117117

118118
for &n_ues in &[8usize, 64, 256, 512, 1024] {
119119
let throughputs: Vec<f64> = (1..=n_ues).map(|i| i as f64 * 1e6).collect();
120-
group.bench_with_input(
121-
BenchmarkId::new("ues", n_ues),
122-
&throughputs,
123-
|b, tp| {
124-
b.iter(|| black_box(jain_fairness(black_box(tp))))
125-
},
126-
);
120+
group.bench_with_input(BenchmarkId::new("ues", n_ues), &throughputs, |b, tp| {
121+
b.iter(|| black_box(jain_fairness(black_box(tp))))
122+
});
127123
}
128124
group.finish();
129125
}

crates/6g-ntn/benches/ntn_capacity.rs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88
//! cargo bench -p sixg-ntn --bench ntn_capacity
99
1010
use criterion::{black_box, criterion_group, criterion_main, BenchmarkId, Criterion, Throughput};
11+
use sixg_common::types::Position3D;
1112
use sixg_common::types::{Distance, PowerDb, UeId};
1213
use sixg_ntn::{
1314
handover::{leo_propagation_delay_ms, HandoverDecision, HandoverTrigger, NtnHandoverManager},
1415
NtnLayer, NtnNode,
1516
};
16-
use sixg_common::types::Position3D;
1717

1818
/// Benchmark handover evaluation across altitude tiers (LEO / HAPS / GEO).
1919
///
@@ -34,12 +34,16 @@ fn bench_ntn_handover_latency(c: &mut Criterion) {
3434
let delay_ms = leo_propagation_delay_ms(Distance::from_m(alt_m));
3535
let triggers = vec![HandoverTrigger::PropagationDelayExceeded { delay_ms }];
3636

37-
group.bench_with_input(BenchmarkId::new("altitude", label), &triggers, |b, trigs| {
38-
b.iter(|| {
39-
let decision = mgr.evaluate(black_box(UeId(1)), black_box(trigs));
40-
black_box(decision)
41-
})
42-
});
37+
group.bench_with_input(
38+
BenchmarkId::new("altitude", label),
39+
&triggers,
40+
|b, trigs| {
41+
b.iter(|| {
42+
let decision = mgr.evaluate(black_box(UeId(1)), black_box(trigs));
43+
black_box(decision)
44+
})
45+
},
46+
);
4347
}
4448
group.finish();
4549
}

crates/6g-phy/benches/phy_capacity.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@
88
//! cargo bench -p sixg-phy --bench phy_capacity
99
1010
use criterion::{black_box, criterion_group, criterion_main, BenchmarkId, Criterion, Throughput};
11+
use sixg_common::types::SnrDb;
1112
use sixg_common::types::{Distance, Frequency, SnrLinear};
1213
use sixg_phy::{
1314
path_loss_db,
1415
ris::{RisChannel, RisConfig},
1516
waveform::{bpsk_ber_awgn, Waveform},
1617
};
17-
use sixg_common::types::SnrDb;
1818

1919
/// Benchmark path loss computation across a range of batch sizes.
2020
///

crates/6g-phy/src/validation.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,10 @@ use sixg_common::{
2323

2424
use crate::{
2525
spectrum::fspl_db,
26-
waveform::{adc_sqnr_db, bpsk_ber_awgn, ofdm_ber_high_doppler, phase_noise_snr_linear,
27-
WaveformImpairments},
26+
waveform::{
27+
adc_sqnr_db, bpsk_ber_awgn, ofdm_ber_high_doppler, phase_noise_snr_linear,
28+
WaveformImpairments,
29+
},
2830
};
2931

3032
/// Phase-1 analytical validation for the `6g-phy` crate.

crates/6g-semantic/benches/semantic_capacity.rs

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,15 @@ fn bench_semantic_encode_throughput(c: &mut Criterion) {
1919

2020
// Payload sizes: 64 B, 512 B, 4 KB, 16 KB, 64 KB
2121
for &size in &[64usize, 512, 4_096, 16_384, 65_536] {
22-
let payload: Vec<u8> = (0..size)
23-
.map(|i| b'a' + (i % 26) as u8)
24-
.collect();
22+
let payload: Vec<u8> = (0..size).map(|i| b'a' + (i % 26) as u8).collect();
2523

2624
group.throughput(Throughput::Bytes(size as u64));
27-
group.bench_with_input(
28-
BenchmarkId::new("payload_bytes", size),
29-
&payload,
30-
|b, p| {
31-
b.iter(|| {
32-
let encoded = codec.encode(black_box(p));
33-
black_box(encoded)
34-
})
35-
},
36-
);
25+
group.bench_with_input(BenchmarkId::new("payload_bytes", size), &payload, |b, p| {
26+
b.iter(|| {
27+
let encoded = codec.encode(black_box(p));
28+
black_box(encoded)
29+
})
30+
});
3731
}
3832
group.finish();
3933
}

0 commit comments

Comments
 (0)