asupersync_conformance/bench/
mod.rs1use crate::RuntimeInterface;
4use serde::{Deserialize, Serialize};
5use std::time::Duration;
6
7pub mod benchmarks;
8pub mod report;
9pub mod runner;
10pub mod stats;
11
12pub use benchmarks::default_benchmarks;
13pub use report::{
14 render_console_summary, write_html_comparison_report, write_html_report, write_json_report,
15};
16pub use runner::{
17 BenchAllocSnapshot, BenchAllocStats, BenchComparisonResult, BenchComparisonSummary,
18 BenchConfig, BenchOutput, BenchRunResult, BenchRunSummary, BenchRunner, BenchThresholds,
19 RegressionCheck, RegressionConfig, RegressionMetric, run_benchmark_comparison,
20};
21pub use stats::{Comparison, ComparisonConfidence, Stats, StatsError};
22
23#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
25pub enum BenchCategory {
26 TaskSpawn,
28 TaskSwitch,
30 ChannelThroughput,
32 ChannelLatency,
34 MutexContention,
36 TimerAccuracy,
38 IoThroughput,
40 IoLatency,
42}
43
44pub struct Benchmark<R: RuntimeInterface> {
46 pub id: &'static str,
48 pub name: &'static str,
50 pub description: &'static str,
52 pub category: BenchCategory,
54 pub warmup: u32,
56 pub iterations: u32,
58 pub bench_fn: Box<dyn Fn(&R) -> Duration + Send + Sync>,
60}
61
62impl<R: RuntimeInterface> Benchmark<R> {
63 pub fn new(
65 id: &'static str,
66 name: &'static str,
67 description: &'static str,
68 category: BenchCategory,
69 warmup: u32,
70 iterations: u32,
71 bench_fn: impl Fn(&R) -> Duration + Send + Sync + 'static,
72 ) -> Self {
73 Self {
74 id,
75 name,
76 description,
77 category,
78 warmup,
79 iterations,
80 bench_fn: Box::new(bench_fn),
81 }
82 }
83}
84
85#[macro_export]
87macro_rules! benchmark {
88 (
89 id: $id:literal,
90 name: $name:literal,
91 description: $desc:literal,
92 category: $cat:expr,
93 warmup: $warmup:expr,
94 iterations: $iters:expr,
95 bench: |$rt:ident| $body:expr
96 ) => {
97 $crate::bench::Benchmark::new($id, $name, $desc, $cat, $warmup, $iters, |$rt| $body)
98 };
99}