///|
fn benchmark_kind(index : Int) -> FeatureKind {
match index % 4 {
0 => FeatureKind::Hole
1 => FeatureKind::Shaft
2 => FeatureKind::Plane
_ => FeatureKind::Cylinder
}
}
///|
fn benchmark_kind_text(kind : FeatureKind) -> String {
match kind {
Hole => "hole"
Shaft => "shaft"
Plane => "plane"
Slot => "slot"
Circle => "circle"
Cylinder => "cylinder"
Datum => "datum"
}
}
///|
/// Generate the fixed 32-feature benchmark catalog.
pub fn benchmark_features() -> Array[Feature] {
let features = []
for i in 0..<32 {
let kind = benchmark_kind(i)
features.push({
id: "F" + i.to_string(),
kind,
nominal: 10.0 + i.to_double(),
lower: -0.1,
upper: 0.1,
datum: i % 8 == 0,
})
}
features
}
///|
/// Generate the fixed four-device benchmark catalog.
pub fn benchmark_devices() -> Array[Device] {
let kinds = [
FeatureKind::Hole,
FeatureKind::Shaft,
FeatureKind::Plane,
FeatureKind::Slot,
FeatureKind::Circle,
FeatureKind::Cylinder,
FeatureKind::Datum,
]
[
new_device("bench-01", 0.01, 100.0, kinds),
new_device("bench-02", 0.02, 100.0, kinds),
new_device("bench-03", 0.05, 100.0, kinds),
new_device("bench-04", 0.1, 100.0, kinds),
]
}
///|
/// Generate one centered observation per benchmark feature.
pub fn benchmark_observations() -> Array[Observation] {
let observations = []
for i in 0..<32 {
observations.push(
new_observation("F" + i.to_string(), 10.0 + i.to_double(), 3),
)
}
observations
}
///|
/// Build the deterministic benchmark plan.
pub fn benchmark_plan() -> MeasurementPlan {
plan(part_id="benchmark-part", benchmark_features(), benchmark_devices())
}
///|
/// Build the CSV representation used by the parser benchmark.
pub fn benchmark_feature_csv() -> String {
let features = benchmark_features()
let mut output = "id,kind,nominal,lower,upper,datum\n"
for feature in features {
output = output +
feature.id +
"," +
benchmark_kind_text(feature.kind) +
"," +
feature.nominal.to_string() +
"," +
feature.lower.to_string() +
"," +
feature.upper.to_string() +
"," +
feature.datum.to_string() +
"\n"
}
output
}