Skip to content

Commit 60d12d4

Browse files
committed
force garbage collection in benchmarks
1 parent 42ac96c commit 60d12d4

File tree

1 file changed

+49
-26
lines changed

1 file changed

+49
-26
lines changed

benchmark/benchmark.jl

Lines changed: 49 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -29,23 +29,27 @@ for n in v
2929
a0 = rand(Bool, n, n)
3030
b0 = rand(Bool, n, n)
3131

32+
GC.gc(true)
3233
t1 = let a1 = ZZ2Matrix(a0), b1 = ZZ2Matrix(b0)
3334
prettytime(@b $a1 * $b1)
3435
end
36+
GC.gc(true)
3537
if n <= 1000
3638
t2 = let a2 = map(ZZ2, a0), b2 = map(ZZ2, b0)
3739
prettytime(@b $a2 * $b2)
3840
end
3941
else
4042
t2 = skipped
4143
end
44+
GC.gc(true)
4245
if n <= 500
4346
t3 = let a3 = matrix(R3, a0), b3 = matrix(R3, b0)
4447
prettytime(@b $a3 * $b3)
4548
end
4649
else
4750
t3 = skipped
4851
end
52+
GC.gc(true)
4953
t4 = let a4 = matrix(R4, a0), b4 = matrix(R4, b0)
5054
prettytime(@b $a4 * $b4)
5155
end
@@ -68,23 +72,27 @@ s = """
6872
for n in v
6973
a0 = rand(Bool, n, n)
7074

75+
GC.gc(true)
7176
t1 = let a1 = ZZ2Matrix(a0)
7277
prettytime(@b Modulo2.rank($a1))
7378
end
79+
GC.gc(true)
7480
if n <= 500
7581
t2 = let a2 = map(R2, a0)
7682
prettytime(@b rankx($a2))
7783
end
7884
else
7985
t2 = skipped
8086
end
87+
GC.gc(true)
8188
if n <= 500
8289
t3 = let a3 = matrix(R3, a0)
8390
prettytime(@b AbstractAlgebra.rank($a3))
8491
end
8592
else
8693
t3 = skipped
8794
end
95+
GC.gc(true)
8896
t4 = let a4 = matrix(R4, a0)
8997
prettytime(@b AbstractAlgebra.rank($a4))
9098
end
@@ -107,23 +115,30 @@ s = """
107115
for n in v
108116
a0 = rand(Bool, n, n)
109117

110-
a1 = ZZ2Matrix(a0)
111-
a2 = map(R2, a0)
112-
a3 = matrix(R3, a0)
113-
a4 = matrix(R4, a0)
114-
115-
t1 = prettytime(@b det($a1))
116-
if n <= 1000
117-
t2 = prettytime(@b detx($a2))
118+
GC.gc(true)
119+
t1 = let a1 = ZZ2Matrix(a0)
120+
prettytime(@b det($a1))
121+
end
122+
GC.gc(true)
123+
t2 = if n <= 1000
124+
let a2 = map(R2, a0)
125+
prettytime(@b detx($a2))
126+
end
118127
else
119-
t2 = skipped
128+
skipped
120129
end
121-
if n <= 500
122-
t3 = prettytime(@b det($a3))
130+
GC.gc(true)
131+
t3 = if n <= 500
132+
let a3 = matrix(R3, a0)
133+
prettytime(@b det($a3))
134+
end
123135
else
124-
t3 = skipped
136+
skipped
137+
end
138+
GC.gc(true)
139+
t4 = let a4 = matrix(R4, a0)
140+
prettytime(@b det($a4))
125141
end
126-
t4 = prettytime(@b det($a4))
127142

128143
s0 = "| $n | $t1 | $t2 | $t3 | $t4 |\n"
129144

@@ -141,30 +156,38 @@ s = """
141156
| ---: | ---: | ---: | ---: | ---: |
142157
"""
143158
for n in v
144-
local a0, a1
159+
local a0
145160

146161
while true
147162
a0 = rand(Bool, n, n)
148163
a1 = ZZ2Matrix(a0)
149164
iszero(det(a1)) || break
150165
end
151166

152-
a2 = map(R2, a0)
153-
a3 = matrix(R3, a0)
154-
a4 = matrix(R4, a0)
155-
156-
t1 = prettytime(@b inv($a1))
157-
if n <= 1000
158-
t2 = prettytime(@b detx($a2))
167+
GC.gc(true)
168+
t1 = let a1 = ZZ2Matrix(a0)
169+
prettytime(@b inv($a1))
170+
end
171+
GC.gc(true)
172+
t2 = if n <= 1000
173+
let a2 = map(R2, a0)
174+
prettytime(@b detx($a2))
175+
end
159176
else
160-
t2 = skipped
177+
skipped
161178
end
162-
if n <= 500
163-
t3 = prettytime(@b inv($a3))
179+
GC.gc(true)
180+
t3 = if n <= 500
181+
let a3 = matrix(R3, a0)
182+
prettytime(@b inv($a3))
183+
end
164184
else
165-
t3 = skipped
185+
skipped
186+
end
187+
GC.gc(true)
188+
t4 = let a4 = matrix(R4, a0)
189+
prettytime(@b inv($a4))
166190
end
167-
t4 = prettytime(@b inv($a4))
168191

169192
s0 = "| $n | $t1 | $t2 | $t3 | $t4 |\n"
170193

0 commit comments

Comments
 (0)