-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmany.nim
41 lines (32 loc) · 875 Bytes
/
many.nim
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
import criterion
type
Z = int
var cfg = newDefaultConfig()
cfg.warmupBudget = 0.1
cfg.budget = 0.1
benchmark cfg:
proc foo(x, y: int) {.measure: [(1,2)].} =
doAssert x + y == 1 + 2
benchmark cfg:
proc foo(x, y: int) {.measure: @[(1,2)].} =
doAssert x + y == 1 + 2
benchmark cfg:
proc foo(x: int) {.measure: 0..10.} =
doAssert x >= 0 and x <= 10
benchmark cfg:
iterator bar(): (int, int) =
yield (42, 42)
proc foo(x, y: int) {.measure: bar.} =
doAssert x + y == 42 + 42
benchmark cfg:
func foo(x:int,w:float): void {.measure: [(1,1.0),(2,2.0)].} =
discard
func foo(x:Z): void {.measure: [1.Z].} =
discard
benchmark cfg:
type O = object
x: int
func dodo(x: O) {.measure: [O(x:42)].} =
doAssert x.x == 42
func dodo(x: array[3,int]) {.measure: [[1,2,3]].} =
doAssert x.len == 3 and (x[0] + x[1] + x[2]) == 6