-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDistReportMain.lean
More file actions
38 lines (32 loc) · 1.7 KB
/
Copy pathDistReportMain.lean
File metadata and controls
38 lines (32 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import StrataGenerators.DistReport
/-!
# `dist-report` driver
Prints how often the shapes that the suite's properties discriminate on appear, per
property family and per tuning profile. `StrataGenerators.DistReport` says what each
column means, and `StrataGenerators.TuningProfiles` says what each profile tries to buy.
```bash
lake exe dist-report [samples] [maxSize] [--stmt] [--proc] [--cmd] [--expr] [--prog]
```
`samples` (default 200) is per profile per family, `maxSize` (default 100) is the
Plausible size the draws cycle through. With no family flag, all five run.
To compare a *property's* verdict across profiles, register it with
`TestDecl.underTunings` instead. `StrataTests/Stmt.lean` shows how.
-/
def main (args : List String) : IO UInt32 := do
let flags := args.filter (·.startsWith "--")
let positional := args.filter (fun a => !a.startsWith "--")
let samples := (positional[0]? >>= String.toNat?).getD 200
let maxSize := (positional[1]? >>= String.toNat?).getD 100
let all := ["stmt", "proc", "cmd", "expr", "prog"]
-- An unrecognised flag is an error rather than a no-op. If the driver ignores one, the output reads
-- as though that family was measured when nothing was. A `--props` flag stayed documented but
-- unbuilt for exactly that reason.
let unknown := flags.filter (fun f => !all.any (fun n => f == s!"--{n}"))
unless unknown.isEmpty do
IO.eprintln s!"dist-report: unknown flag(s) {" ".intercalate unknown}; \
expected any of {" ".intercalate (all.map (s!"--{·}"))}"
return 1
let asked := all.filter (fun f => flags.contains s!"--{f}")
let families := if asked.isEmpty then all else asked
StrataGenerators.DistReport.report samples maxSize families
return 0