Skip to content

Commit 505b38b

Browse files
committed
Adding grouping of space tests
1 parent f5afc04 commit 505b38b

File tree

2 files changed

+97
-85
lines changed

2 files changed

+97
-85
lines changed

bench/Space.hs

Lines changed: 96 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -14,90 +14,102 @@ main :: IO ()
1414
main =
1515
mainWith
1616
(do setColumns [Case, Allocated, GCs]
17-
sequence_
18-
[ validateAction
19-
("pollEvent " ++ show i)
20-
pollEventTest
21-
i
22-
(\weight ->
23-
if weightGCs weight > 0
24-
then Just "Non-zero number of garbage collections!"
25-
else if weightAllocatedBytes weight > 2000
26-
then Just
27-
"Allocated >2KB! Allocations should be constant."
28-
else Nothing)
29-
| i <- [1, 10, 100, 1000, 10000]
30-
]
31-
sequence_
32-
[ validateAction
33-
("pollEvent + clear " ++ show i)
34-
pollEventClearTest
35-
i
36-
(\weight ->
37-
if weightGCs weight > 0
38-
then Just "Non-zero number of garbage collections!"
39-
else if weightAllocatedBytes weight > 3000
40-
then Just
41-
"Allocated >3KB! Allocations should be constant."
42-
else Nothing)
43-
| i <- [1, 10, 100, 1000, 10000]
44-
]
45-
sequence_
46-
[ validateAction
47-
("pollEvent + present " ++ show i)
48-
pollEventPresentTest
49-
i
50-
(\weight ->
51-
if weightGCs weight > 0
52-
then Just "Non-zero number of garbage collections!"
53-
else if weightAllocatedBytes weight > 4000
54-
then Just
55-
"Allocated >4KB! Allocations should be constant."
56-
else Nothing)
57-
| i <- [1, 10, 100, 1000]
58-
]
59-
sequence_
60-
[ validateAction
61-
("pollEvent + drawColor " ++ show i)
62-
pollEventDrawColorTest
63-
i
64-
(\weight ->
65-
if weightGCs weight > 0
66-
then Just "Non-zero number of garbage collections!"
67-
else if weightAllocatedBytes weight > 4000
68-
then Just
69-
"Allocated >KB! Allocations should be constant."
70-
else Nothing)
71-
| i <- [1, 10, 100, 1000, 2000]
72-
]
73-
sequence_
74-
[ validateAction
75-
("pollEvent + drawRect " ++ show i)
76-
pollEventDrawRectTest
77-
i
78-
(\weight ->
79-
if weightGCs weight > 0
80-
then Just "Non-zero number of garbage collections!"
81-
else if weightAllocatedBytes weight > 4000
82-
then Just
83-
"Allocated >4KB! Allocations should be constant."
84-
else Nothing)
85-
| i <- [1, 10, 100, 1000]
86-
]
87-
sequence_
88-
[ validateAction
89-
("animated rect " ++ show i)
90-
pollEventAnimRectTest
91-
i
92-
(\weight ->
93-
if weightGCs weight > 0
94-
then Just "Non-zero number of garbage collections!"
95-
else if weightAllocatedBytes weight > 4000
96-
then Just
97-
"Allocated >4KB! Allocations should be constant."
98-
else Nothing)
99-
| i <- [1, 10, 100, 1000, 2000]
100-
])
17+
wgroup
18+
"pollEvent"
19+
(sequence_
20+
[ validateAction
21+
("pollEvent " ++ show i)
22+
pollEventTest
23+
i
24+
(\weight ->
25+
if weightGCs weight > 0
26+
then Just "Non-zero number of garbage collections!"
27+
else if weightAllocatedBytes weight > 2000
28+
then Just
29+
"Allocated >2KB! Allocations should be constant."
30+
else Nothing)
31+
| i <- [1, 10, 100, 1000, 10000]
32+
])
33+
wgroup
34+
"pollEvent+clear"
35+
(sequence_
36+
[ validateAction
37+
("pollEvent + clear " ++ show i)
38+
pollEventClearTest
39+
i
40+
(\weight ->
41+
if weightGCs weight > 0
42+
then Just "Non-zero number of garbage collections!"
43+
else if weightAllocatedBytes weight > 3000
44+
then Just
45+
"Allocated >3KB! Allocations should be constant."
46+
else Nothing)
47+
| i <- [1, 10, 100, 1000, 10000]
48+
])
49+
wgroup
50+
"pollEvent+present"
51+
(sequence_
52+
[ validateAction
53+
("pollEvent + present " ++ show i)
54+
pollEventPresentTest
55+
i
56+
(\weight ->
57+
if weightGCs weight > 0
58+
then Just "Non-zero number of garbage collections!"
59+
else if weightAllocatedBytes weight > 4000
60+
then Just
61+
"Allocated >4KB! Allocations should be constant."
62+
else Nothing)
63+
| i <- [1, 10, 100, 1000]
64+
])
65+
wgroup
66+
"pollEvent+drawColor"
67+
(sequence_
68+
[ validateAction
69+
("pollEvent + drawColor " ++ show i)
70+
pollEventDrawColorTest
71+
i
72+
(\weight ->
73+
if weightGCs weight > 0
74+
then Just "Non-zero number of garbage collections!"
75+
else if weightAllocatedBytes weight > 4000
76+
then Just
77+
"Allocated >KB! Allocations should be constant."
78+
else Nothing)
79+
| i <- [1, 10, 100, 1000, 2000]
80+
])
81+
wgroup
82+
"pollEvent+drawRect"
83+
(sequence_
84+
[ validateAction
85+
("pollEvent + drawRect " ++ show i)
86+
pollEventDrawRectTest
87+
i
88+
(\weight ->
89+
if weightGCs weight > 0
90+
then Just "Non-zero number of garbage collections!"
91+
else if weightAllocatedBytes weight > 4000
92+
then Just
93+
"Allocated >4KB! Allocations should be constant."
94+
else Nothing)
95+
| i <- [1, 10, 100, 1000]
96+
])
97+
wgroup
98+
"animated rect"
99+
(sequence_
100+
[ validateAction
101+
("animated rect " ++ show i)
102+
pollEventAnimRectTest
103+
i
104+
(\weight ->
105+
if weightGCs weight > 0
106+
then Just "Non-zero number of garbage collections!"
107+
else if weightAllocatedBytes weight > 4000
108+
then Just
109+
"Allocated >4KB! Allocations should be constant."
110+
else Nothing)
111+
| i <- [1, 10, 100, 1000, 2000]
112+
]))
101113

102114
-- | Test that merely polling does not allocate or engage the GC.
103115
-- <https://github.com/haskell-game/sdl2/issues/178>

sdl2.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ test-suite sdl-space
145145
main-is: Space.hs
146146
hs-source-dirs: bench
147147
build-depends: base
148-
, weigh
148+
, weigh >= 0.0.8
149149
, linear
150150
, sdl2
151151
, deepseq

0 commit comments

Comments
 (0)