-
Notifications
You must be signed in to change notification settings - Fork 1
/
benchmark.pony
68 lines (57 loc) · 2.14 KB
/
benchmark.pony
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
type Benchmark is (MicroBenchmark | AsyncMicroBenchmark)
// interface iso _IBenchmark
// fun box name(): String
// fun box config(): BenchConfig
// fun box overhead(): _IBenchmark^
trait iso MicroBenchmark
"""
Synchronous benchmarks must provide this trait. The `apply` method defines a
single iteration in a sample. Setup and Teardown are defined by the `before`
and `after` methods respectively. The `before` method runs before a sample
of benchmarks and `after` runs after the all iterations in the sample have
completed. If your benchmark requires setup and/or teardown to occur beween
each iteration of the benchmark, then you must set the configuration of the
benchmark to have `max_iterations = 1`. It should be noted that a larger
`sample_size` may be necessary in this scenario for statistically
significant results.
"""
fun box name(): String
fun box config(): BenchConfig => BenchConfig
fun box overhead(): MicroBenchmark^ => OverheadBenchmark
fun ref before() => None
fun ref apply() ?
fun ref after() => None
trait iso AsyncMicroBenchmark
fun box name(): String
fun box config(): BenchConfig => BenchConfig
fun box overhead(): AsyncMicroBenchmark^ => AsyncOverheadBenchmark
fun ref before(c: AsyncBenchContinue) => c.complete()
// TODO document (single iteration!!)
fun ref apply(c: AsyncBenchContinue) ?
fun ref after(c: AsyncBenchContinue) => c.complete()
interface tag BenchmarkList
fun tag benchmarks(bench: PonyBench)
// TODO documentation
class val BenchConfig
let samples: USize
let max_iterations: U64
let max_sample_time: U64
new val create(
samples': USize = 20,
max_iterations': U64 = 1_000_000_000,
max_sample_time': U64 = 100_000_000)
=>
samples = samples'
max_iterations = max_iterations'
max_sample_time = max_sample_time'
class iso OverheadBenchmark is MicroBenchmark
fun name(): String =>
"Benchmark Overhead"
fun ref apply() =>
DoNotOptimise[None](None)
DoNotOptimise.observe()
class iso AsyncOverheadBenchmark is AsyncMicroBenchmark
fun name(): String =>
"Benchmark Overhead"
fun ref apply(c: AsyncBenchContinue) =>
c.complete()