Skip to content

Commit d278c58

Browse files
committed
docs: basic documentation finished
1 parent e42c520 commit d278c58

13 files changed

+1134
-430
lines changed

docs/data-definition.scrbl

Lines changed: 193 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,193 @@
1+
#lang scribble/manual
2+
3+
@require[
4+
gtp-plot/configuration-info
5+
(for-label
6+
gtp-plot/configuration-info
7+
gtp-plot/performance-info
8+
gtp-plot/sample-info
9+
gtp-plot/util
10+
racket/base
11+
racket/contract
12+
(only-in racket/math natural?))]
13+
14+
@title[#:tag "gtp-data-definition"]{Data Definitions}
15+
16+
@section[#:tag "gtp-configuration-info"]{Configuration Info}
17+
@defmodule[gtp-plot/configuration-info]
18+
19+
@defstruct[configuration-info ([id any/c] [num-types natural?] [runtime* nonnegative-real/c]) #:prefab]{
20+
A @deftech{configuration info} structure describes the performance of
21+
one gradually-typed configuration of a program.
22+
}
23+
24+
@defproc[(configuration-info->id [cfg configuration-info?]) any/c]{
25+
Returns the configuration's identifier.
26+
The identifier should describe the type annotations in the configuration,
27+
relative to the possible type annotations in the program.
28+
}
29+
30+
@defproc[(configuration-info->num-types [cfg configuration-info?]) natural?]{
31+
Return the number of type annotations in the configuration.
32+
}
33+
34+
@defproc[(configuration-info->runtime* [cfg configuration-info?]) (listof nonnegative-real/c)]{
35+
Return the running times associated with the configuration.
36+
}
37+
38+
@defproc[(configuration-info->mean-runtime [cfg configuration-info?]) nonnegative-real/c]{
39+
Return the mean running time associated with the configuration.
40+
}
41+
42+
43+
@section[#:tag "gtp-performance-info"]{Performance Info}
44+
@defmodule[gtp-plot/performance-info]
45+
46+
@defidform[performance-info]{
47+
A struct type, exported to allow subtyping.
48+
49+
A @deftech{performance info} struct contains performance data for one
50+
gradually typed program.
51+
}
52+
53+
@defproc[(performance-info? [x any/c]) boolean?]{
54+
Predicate for @tech{performance info} structures.
55+
}
56+
57+
@defproc[(make-performance-info [name symbol?]
58+
[#:src src path-string?]
59+
[#:num-units num-units natural?]
60+
[#:baseline-runtime baseline-runtime nonnegative-real/c]
61+
[#:untyped-runtime untyped-runtime nonnegative-real/c]
62+
[#:typed-runtime typed-runtime nonnegative-real/c]
63+
[#:make-in-configurations make-in-configurations (-> performance-info? (sequence/c configuration-info?))])
64+
performance-info?]{
65+
Builds a @tech{performance info} structure for the data for a gradually-typed program.
66+
67+
@itemlist[
68+
@item{
69+
@racket[name] is the name of the program;
70+
}
71+
@item{
72+
@racket[src] is a performance data for the program,
73+
this file can be in any format that @racket[make-in-configurations] understands;
74+
}
75+
@item{
76+
@racket[num-units] is the number of @tech{typeable components} in the program;
77+
}
78+
@item{
79+
@racket[baseline-runtime] is the performance of the given program without any gradual typing;
80+
}
81+
@item{
82+
@racket[untyped-runtime] is the performance of the program with no type annotations,
83+
this may be the same as the baseline runtime;
84+
}
85+
@item{
86+
@racket[typed-runtime] is the performance of the program when fully-typed;
87+
}
88+
@item{
89+
@racket[make-in-configurations] is a function that accepts a @tech{performance info}
90+
structure (specifically, itself) and returns a sequence with the data
91+
for each configuration in the program.
92+
}
93+
]
94+
}
95+
96+
@deftogether[(
97+
@defproc[(performance-info->name [pi performance-info?]) symbol?]
98+
@defproc[(performance-info->src [pi performance-info?]) path-string?]
99+
@defproc[(performance-info->num-units [pi performance-info?]) natural?]
100+
@defproc[(performance-info->baseline-runtime [pi performance-info?]) nonnegative-real/c]
101+
@defproc[(performance-info->untyped-runtime [pi performance-info?]) nonnegative-real/c]
102+
@defproc[(performance-info->typed-runtime [pi performance-info?]) nonnegative-real/c]
103+
)]{
104+
Getter functions.
105+
}
106+
107+
@defproc[(performance-info->num-configurations [pi performance-info?]) natural?]{
108+
Return the number of configurations in the program.
109+
Same as @racket[(expt 2 (performance-info->num-units _pi))].
110+
}
111+
112+
@defproc[(in-configurations [pi performance-info?]) (sequence/c configuration-info?)]{
113+
Returns all configuration data from the given dataset.
114+
}
115+
116+
@defproc[(deliverable [D nonnegative-real/c]) (-> performance-info? natural?)]{
117+
Returns a predicate that counts the number of @racket[D]-@emph{deliverable} configurations
118+
in a program.
119+
120+
A configuration is @racket[D]-@emph{deliverable} if its performance is at most
121+
@racket[D]x slower than the baseline runtime.
122+
}
123+
124+
@defproc*[(
125+
[(overhead [pi performance-info?] [t nonnegative-real/c]) nonnegative-real/c]
126+
[(overhead [pi performance-info?]) (-> nonnegative-real/c nonnegative-real/c)]
127+
)]{
128+
@racket[(overhead pi t)] returns the overhead of the running time @racket[t]
129+
relative to the baseline runtime of the given program.
130+
The second form is a curried version of the first.
131+
}
132+
133+
@defproc[(count-configuration [pi performance-info?] [f (-> configuration-info? any)]) natural?]{
134+
Counts the number of configurations that satisfy the given predicate.
135+
}
136+
137+
@defproc[(filter-configurations [pi performance-info?] [f (-> nonnegative-real/c any)]) (listof configuration-info?)]{
138+
Returns a list of configurations that satisfy the given performance predicate.
139+
}
140+
141+
@deftogether[(
142+
@defproc[(max-overhead [pi performance-info?]) nonnegative-real/c]
143+
@defproc[(mean-overhead [pi performance-info?]) nonnegative-real/c]
144+
@defproc[(min-overhead [pi performance-info?]) nonnegative-real/c]
145+
)]{
146+
Return the minimum, average, and maximum overheads in the given dataset.
147+
}
148+
149+
@deftogether[(
150+
@defproc[(typed/baseline-ratio [pi performance-info?]) nonnegative-real/c]
151+
@defproc[(typed/untyped-ratio [pi performance-info?]) nonnegative-real/c]
152+
@defproc[(untyped/baseline-ratio [pi performance-info?]) nonnegative-real/c]
153+
)]{
154+
Return a performance ratio.
155+
For example, the typed/untyped ratio is the performance of the fully-typed
156+
configuration divided by the performance of the untyped configuration.
157+
}
158+
159+
@defproc[(fold/mean-runtime [pi performance-info?] [f (-> any/c nonnegative-real/c any)] [#:init init (or/c #f (-> nonnegative-real/c any)) #f]) any]{
160+
Folds over a dataset.
161+
162+
If @racket[init] is @racket[#false], then the initial accumulator is the
163+
mean running time of some configuration and @racket[f] must return a nonnegative real number.
164+
If @racket[init] is a procedure, then the initial accumulator is the
165+
result of applying @racket[init] to an arbitrary configuration.
166+
}
167+
168+
169+
170+
@section[#:tag "gtp-sample-info"]{Sample Info}
171+
@defmodule[gtp-plot/sample-info]
172+
173+
@defproc[(sample-info? [x any/c]) boolean?]{
174+
Predicate for @deftech{sample info} structures.
175+
}
176+
177+
@defproc[(make-sample-info [pi performance-info?] [samples (listof path-string?)]) sample-info?]{
178+
Make a @tech{sample info} structure from a @tech{performance info} structure
179+
and sampled datasets.
180+
Logs an @racket['error]-level message to @racket[gtp-plot-logger] if
181+
the sampled datasets do not all contain the same number of configurations.
182+
}
183+
184+
@defproc[(sample-info->sample-size [si sample-info?]) natural?]{
185+
Count the number of configurations in each sample in the given @tech{sample info}
186+
structure.
187+
}
188+
189+
@defproc[(sample-info->performance-info* [si sample-info?]) (listof performance-info?)]{
190+
Expand a @tech{sample info} structure to a list of @tech{performance info} structures.
191+
Each structure represents one sample of configurations.
192+
}
193+

0 commit comments

Comments
 (0)