| 1 | package main |
| 2 | |
| 3 | import ( |
| 4 | "errors" |
| 5 | "fmt" |
| 6 | "strings" |
| 7 | |
| 8 | "reasonix/internal/ablation" |
| 9 | ) |
| 10 | |
| 11 | // experimentAxes is the validated set of fixed axes one suite invocation runs |
| 12 | // on. They are resolved together so a second bad flag is reported alongside |
| 13 | // the first instead of being masked by an early exit. |
| 14 | type experimentAxes struct { |
| 15 | cache, anchor string |
| 16 | arm ablation.Set |
| 17 | } |
| 18 | |
| 19 | func resolveExperimentAxes(ablate, cache, anchor string) (experimentAxes, error) { |
| 20 | a, aerr := ablation.Parse(ablate) |
| 21 | c, cerr := normalizeCacheArm(cache) |
| 22 | an, anerr := normalizeAnchorArm(anchor) |
| 23 | return experimentAxes{cache: c, anchor: an, arm: a}, errors.Join(aerr, cerr, anerr) |
| 24 | } |
| 25 | |
| 26 | // benchmarkProfileStandard keeps the historical JSON field readable while the |
| 27 | // harness itself has one execution contract. It is metadata, not an arm. |
| 28 | const benchmarkProfileStandard = "standard" |
| 29 | |
| 30 | const ( |
| 31 | benchmarkCacheCold = "cold" |
| 32 | benchmarkCacheWarm = "warm" |
| 33 | ) |
| 34 | |
| 35 | func normalizeCacheArm(arm string) (string, error) { |
| 36 | switch strings.ToLower(strings.TrimSpace(arm)) { |
| 37 | case "", benchmarkCacheCold: |
| 38 | return benchmarkCacheCold, nil |
| 39 | case benchmarkCacheWarm: |
| 40 | return benchmarkCacheWarm, nil |
| 41 | default: |
| 42 | return "", fmt.Errorf("unknown cache arm %q (want cold or warm)", arm) |
| 43 | } |
| 44 | } |
| 45 |