Skip to content

Commit 4a96f51

Browse files
committed
locli: create reports as typst documents
1 parent 101fe39 commit 4a96f51

File tree

6 files changed

+375
-29
lines changed

6 files changed

+375
-29
lines changed

bench/locli/locli.cabal

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ license-files: LICENSE
1616
-- The module src-quick/Graphics/EasyPlot.hs is a forked, and heavily modded,
1717
-- version of the easyplot-1.0 package by Julian Bertram.
1818
extra-doc-files: CHANGELOG.md
19+
data-files: report-templates/typst/*
1920
build-type: Simple
2021

2122
common project-config
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
#set page(paper: "a4")
2+
3+
// these settings make the output look more LaTeX-like
4+
// #set page(margin: 1.75in)
5+
#set par(leading: 0.55em, spacing: 0.55em, first-line-indent: 1.8em, justify: true)
6+
// #set text(font: "Ubuntu")
7+
// #show raw: set text(font: "Ubuntu Mono")
8+
#show heading: set block(above: 1.5em, below: 1.2em)
9+
10+
#metadata("{{ report.tag }}.{{ base.fileInfix }}.pdf") <export_file_name>
11+
12+
13+
// Semibold row descriptions
14+
#show table.cell.where(x: 0): set text(weight: "semibold")
15+
16+
// No strokes inside table body; left alignment for row descriptions only
17+
#let frame(stroke) = (x, y) => (
18+
left: if x > 0 { 0pt } else { stroke },
19+
right: stroke,
20+
top: if y < 2 { stroke } else { 0pt },
21+
bottom: stroke,
22+
)
23+
#set table(
24+
stroke: frame(1pt),
25+
align: (x, _) => if x == 0 { left } else { right }
26+
)
27+
28+
// table coloring
29+
#let gr(c) = table.cell(fill: green.lighten(60%))[c]
30+
31+
32+
// #+CONSTANTS: base=../../{{ base.meta.tag }}/analysis
33+
// {% for run in runs %}
34+
// #+CONSTANTS: run{{ run.index }}=../../{{ run.value.meta.tag }}/analysis
35+
36+
37+
38+
The Title Page
39+
40+
{{ report.target }} against {{ base.ver }}
41+
42+
{{ base.workload }} workload
43+
{{ report.author }}, Cardano Performance team
44+
{{ report.date }}
45+
46+
#pagebreak()
47+
48+
49+
#set page(numbering: "1")
50+
#counter(page).update(1)
51+
52+
#outline()
53+
54+
#pagebreak()
55+
56+
= Manifest
57+
58+
We compare {% for run in runs %}{%if !run.first%}{%if !run.last%}, {%else%} and {%endif%}{%endif%}`{{ run.value.ver }}` ({{ run.value.meta.era | toTitle }}){% endfor %} relative to `{{ base.ver }}` ({{ base.meta.era | toTitle }}), under {{ base.workload }} workload.
59+
60+
{% include "table_summary.ede" with table = summary %}
61+
62+
#pagebreak()
63+
64+
= Analysis
65+
66+
67+
#pagebreak()
68+
69+
70+
= Observations
71+
72+
== Resources
73+
74+
+ ...
75+
76+
== Forging
77+
78+
+ ...
79+
80+
== Peer propagation
81+
82+
+ ...
83+
84+
== End-to-end propagation
85+
86+
+ ...
87+
88+
89+
#pagebreak()
90+
91+
= Appendix A: charts
92+
93+
== Cluster performance charts
94+
95+
96+
#pagebreak()
97+
98+
99+
#set par(
100+
first-line-indent: (amount: 0pt, all: true),
101+
spacing: 1.35em
102+
)
103+
104+
= Appendix B: data dictionary
105+
106+
== Block propagation metrics
107+
108+
{% for m in dictionary.dBlockProp %}
109+
*{{ m.value.deShortDesc }}* (_{{ m.value.deField }}_) -- {{ m.value.deDescription }}
110+
111+
{% endfor %}
112+
113+
== Cluster performance metrics
114+
115+
{% for m in dictionary.dClusterPerf %}
116+
*{{ m.value.deShortDesc }}* (_{{ m.value.deField }}_) -- {{ m.value.deDescription }}
117+
118+
{% endfor %}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
2+
3+
#table(
4+
columns: {{ table.header | length }},
5+
6+
table.header(
7+
{% for col in table.header %}{{ col.value.cont | justifyRight(col.value.width) }}, {% endfor %}
8+
),
9+
10+
{% for row in table.rows %}
11+
{% for col in row.value %}{{ col.value.cont | justifyRight(col.value.width) }}, {% endfor %}
12+
{% endfor %}
13+
)

bench/locli/src/Cardano/Command.hs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,7 @@ writerOpt ctor desc rcFormat = do
329329
AsOrg -> (,) "org" " as Org-mode table"
330330
AsReport -> (,) "org-report" " as Org-mode summary table"
331331
AsPretty -> (,) "pretty" " as text report"
332+
AsTypst -> (,) "typst" " as typst document"
332333

333334
writerOpts :: (RenderConfig -> TextOutputFile -> a) -> String -> Parser a
334335
writerOpts ctor desc = enumFromTo minBound maxBound
@@ -840,7 +841,7 @@ runChainCommand s c@(Compare ede mTmpl outf@(TextOutputFile outfp) runs) = do
840841
<*> readJsonData bpf (CommandError c)
841842
(tmpl, tmplEnv, orgReport) <- case xs of
842843
baseline:deltas@(_:_) -> liftIO $ do
843-
Cardano.Report.generate ede mTmpl baseline deltas
844+
Cardano.Report.generateOrg ede mTmpl baseline deltas
844845
_ -> throwE $ CommandError c $ mconcat
845846
[ "At least two runs required for comparison." ]
846847
liftIO $
@@ -853,6 +854,22 @@ runChainCommand s c@(Compare ede mTmpl outf@(TextOutputFile outfp) runs) = do
853854
liftIO . unlessM (IO.fileExist tmplPath) $
854855
BS.writeFile tmplPath tmpl
855856

857+
(tmpl', tmplEnv', typstReport) <- case xs of
858+
baseline:deltas@(_:_) -> liftIO $ do
859+
Cardano.Report.generateTypst ede mTmpl baseline deltas
860+
_ -> throwE $ CommandError c $ mconcat
861+
[ "At least two runs required for comparison." ]
862+
liftIO $
863+
withFile (outfp `System.FilePath.replaceExtension` "env.typ.json") WriteMode $
864+
\hnd -> BS8.hPutStrLn hnd tmplEnv'
865+
let typstPath = Cardano.Util.replaceExtension outfp "typ"
866+
dumpText "report" [typstReport] (TextOutputFile typstPath)
867+
& firstExceptT (CommandError c)
868+
869+
let tmplPath' = Cardano.Util.replaceExtension outfp "typ.ede"
870+
liftIO . unlessM (IO.fileExist tmplPath) $
871+
BS.writeFile tmplPath' tmpl'
872+
856873
pure s
857874

858875
missingCommandData :: ChainCommand -> [String] -> ExceptT CommandError IO a

bench/locli/src/Cardano/Render.hs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ data RenderFormat
4444
| AsOrg
4545
| AsReport
4646
| AsPretty
47+
| AsTypst
4748
deriving (Eq, Show, Bounded, Enum)
4849

4950
-- | Explain the poor human a little bit of what was going on:
@@ -335,9 +336,14 @@ modeFilename orig@(TextOutputFile f) name = \case
335336
AsOrg -> orig
336337
AsReport -> orig
337338
AsPretty -> orig
339+
AsTypst -> orig
338340

339341
renderAnalysisCDFs :: forall a p. (CDFFields a p, KnownCDF p, ToJSON (a p)) => Anchor -> (Field DSelect p a -> Bool) -> CDF2Aspect -> Maybe [Centile] -> RenderConfig -> a p -> [(Text, [Text])]
340342

343+
-- TODO:MKarg
344+
renderAnalysisCDFs anchor fieldSelr _c2a _centileSelr rc@RenderConfig{rcFormat=AsTypst} x =
345+
renderAnalysisCDFs anchor fieldSelr _c2a _centileSelr rc{rcFormat=AsOrg} x
346+
341347
renderAnalysisCDFs _anchor _fieldSelr _c2a _centileSelr RenderConfig{rcFormat=AsJSON} x = (:[]) . ("",) . (:[]) . LT.toStrict $
342348
encodeToLazyText x
343349

0 commit comments

Comments
 (0)