-
Notifications
You must be signed in to change notification settings - Fork 2
5.3 Benchmarks and Unit Test Module
Relevant source files
The following files were used as context for generating this wiki page:
This section details the performance benchmarking architecture implemented via the Criterion harness in benches/propagate.rs, the dedicated benchmark build profile configurations in Cargo.toml, and the comprehensive unit test module located in src/tests.rs. Together, these components ensure deterministic performance regression tracking across scale boundaries and functional correctness of the routing and neuromodulation subsystems.
Sources: Cargo.toml:48-51, Cargo.toml:80-83, benches/propagate.rs:1-12, src/tests.rs:1-5
The benchmark suite evaluates spiking neural network propagation performance across multiple network topologies, scales, and memory management strategies benches/propagate.rs:3-7. The harness is registered as a non-native test target in Cargo.toml (harness = false) and uses the criterion crate Cargo.toml:46-50.
The benchmarks simulate scaled networks using deterministically generated small-world graphs via generate_small_world benches/propagate.rs:17-21. The test space explores:
-
Neuron Counts (
NEURON_COUNTS):16,256, and4096neurons benches/propagate.rs:13. -
Delay Depths: Short delays (
SHORT_DELAY = 1) and long delays (LONG_DELAY = 16) benches/propagate.rs:14-15. -
Execution Paths: Standard allocating return vs. zero-allocation caller-provided buffer reuse (
propagatevspropagate_into, andpropagate_gradedvspropagate_graded_into) benches/propagate.rs:41-94.
graph TD
sub53_CritMain["criterion_main!(benches)"] --> sub53_Groups["criterion_group!(benches, bench_propagate, bench_propagate_graded)"]
sub53_Groups --> sub53_Prop["bench_propagate(c: &mut Criterion)"]
sub53_Groups --> sub53_Grad["bench_propagate_graded(c: &mut Criterion)"]
sub53_Prop --> sub53_MeshGen["mesh_for(n: usize, max_delay: u16)"]
sub53_Grad --> sub53_MeshGen
sub53_MeshGen --> sub53_SW["generate_small_world()"]
sub53_MeshGen --> sub53_SM["SynapticMesh::new(graph)"]
sub53_Prop --> sub53_Alloc["alloc/{label} (mesh.propagate)"]
sub53_Prop --> sub53_Into["into/{label} (mesh.propagate_into)"]
sub53_Grad --> sub53_GradAlloc["alloc/{label} (mesh.propagate_graded)"]
sub53_Grad --> sub53_GradInto["into/{label} (mesh.propagate_graded_into)"]
classDef default fill:#fff,stroke:#333,stroke-width:2px;
Figure 1: Benchmark Execution Graph from Natural Language Description to benches/propagate.rs Symbols.
Sources: Cargo.toml:46-51, benches/propagate.rs:9-97
To ensure that micro-benchmarks reflect actual release performance while permitting profiling symbols, Cargo.toml defines a dedicated [profile.bench] section Cargo.toml:80-83.
The bench profile inherits optimizations from the release profile (opt-level = 3, lto = "thin", codegen-units = 1) but explicitly retains debug symbols (debug = true, strip = false) so external profilers (e.g., perf, flamegraph) can resolve function symbols Cargo.toml:71-83.
Sources: Cargo.toml:69-83
The unit test module (src/tests.rs) verifies core routing logic, neuromodulatory dynamics, channel constraints, error propagation boundaries, and configuration validation rules src/tests.rs:6-221.
-
Channel Pulse Routing: Validates that pulse activation selectively targets specific channels (
channel_0_pulse_activates_channel_0,channel_1_pulse_activates_channel_1) src/tests.rs:6-25 and that background noise drops below transmission thresholds (background_noise_routes_nowhere) src/tests.rs:28-32. -
Firing Rate Bounds: Asserts that computed firing rates remain strictly bounded within
0.0..=1.0(firing_rates_in_range) src/tests.rs:35-44. -
Plasticity & Feedback: Verifies weight adjustments under positive and negative reinforcement (
positive_feedback_increases_weight,negative_feedback_decreases_weight) src/tests.rs:47-62. -
Neuromodulation Integration: Tests thresholding behavior, leaks, and voltage reset states in
NeuromodNeuron(neuromod_neuron_fires_above_threshold,neuromod_neuron_no_fire_below_threshold) src/tests.rs:85-101. -
Error Context Preservation: Ensures error formatting explicitly distinguishes public and internal routing methods (
route_error_context_reports_public_method_name,route_modulated_error_context_reports_internal_method_name) src/tests.rs:175-205. -
Panic Conditions: Validates defensive assertions such as panicking on zero routing timesteps (
zero_routing_timesteps_panics) src/tests.rs:207-215.
graph TD
sub53_TestMod["src/tests.rs Unit Tests"] --> sub53_CR["ChannelRouter"]
sub53_TestMod --> sub53_NN["NeuromodNeuron"]
sub53_TestMod --> sub53_NS["NeuromodState"]
sub53_CR --> sub53_R1["channel_0_pulse_activates_channel_0"]
sub53_CR --> sub53_R2["positive_feedback_increases_weight"]
sub53_CR --> sub53_R3["global_gain_inhibits_firing"]
sub53_CR --> sub53_R4["route_error_context_reports_public_method_name"]
sub53_NN --> sub53_N1["neuromod_neuron_fires_above_threshold"]
sub53_NN --> sub53_N2["neuromod_neuron_no_fire_below_threshold"]
classDef default fill:#fff,stroke:#333,stroke-width:2px;
Figure 2: Unit Test Verification Mapping from Domain Concepts to src/tests.rs Functions.
Sources: src/tests.rs:6-215
- 1. Overview
- 1.1. Getting Started & Public API
- 1.2. Release History and Versioning
- 2. Core Runtime: SynapticMesh
- 2.1. Propagation APIs and Tick Semantics
- 2.2. Spike Delay Buffer (Ring Buffer)
- 2.3. Core Types and Error Model
- 2.4. Checkpointing and Serde State Restoration
- 3. Topology Subsystem
- 3.1. SynapticGraph and CSR Representation
- 3.2. Topology Generators
- 3.3. Wiring Rules, Dale's Law and Delay Assignment
- 3.4. Topology Digest
- 4. Sparse Maps and Channel Routing
- 4.1. ChannelRouter and RouterConfig
- 4.2. Neuromodulation and Plasticity
- 4.3. SparseSynapticMap (CSR)
- 5. Testing, Benchmarks and Quality Gates
- 5.1. Propagation Contract Tests
- 5.2. Checkpoint Resume Property Suite
- 5.3. Benchmarks and Unit Test Module
- 6. Build, CI and Project Tooling
- 6.1. Cargo Manifest, Profiles and Dependencies
- 6.2. CI Workflows and Packaging Validation
- 6.3. Code Quality, Licensing and Review Gates
- 7. Glossary