@@ -3,6 +3,13 @@ using BenchmarkTools
3
3
4
4
import BenchmarkTools: prettytime, prettymemory
5
5
6
+ @noinline plus (a,b) = a+ b
7
+ @noinline plus! (c,a,b) = broadcast! (+ , c, a, b)
8
+
9
+ @noinline mul (a,b) = a* b
10
+ @noinline mul! (c,a,b) = A_mul_B! (c, a, b)
11
+
12
+
6
13
for T ∈ [Int64, Float64]
7
14
for N ∈ [1 ,2 ,4 ,8 ,16 ,32 ,64 ,128 ,256 ]
8
15
println (" =====================================================================" )
@@ -16,15 +23,15 @@ for T ∈ [Int64, Float64]
16
23
maxnamelength = maximum (namelengths)
17
24
18
25
for v ∈ instances
19
- result = mean (@benchmark + ($ (copy (v)), $ (copy (v))))
26
+ result = mean (@benchmark plus ($ (copy (v)), $ (copy (v))))
20
27
padding = maxnamelength - length (string (typeof (v). name. name))
21
- println (typeof (v). name. name, " :" , " " ^ padding, " v3 = v1 + v2 takes " , prettytime (time (result)), " , " , prettymemory (memory (result)), " (GC " , prettytime (gctime (result)) , " )" )
28
+ println (typeof (v). name. name, " :" , " " ^ padding, " v3 = v1 + v2 takes " , prettytime (time (result)), " , " , prettymemory (memory (result)), " (GC " , prettytime (gctime (result)) , " )" )
22
29
end
23
30
24
31
println ()
25
32
26
33
for v ∈ mutables
27
- result = mean (@benchmark broadcast! ( + , $ (copy (v)), $ (copy (v)), $ (copy (v))))
34
+ result = mean (@benchmark plus! ( $ (copy (v)), $ (copy (v)), $ (copy (v))))
28
35
padding = maxnamelength - length (string (typeof (v). name. name))
29
36
println (typeof (v). name. name, " :" , " " ^ padding, " v3 .= +.(v1, v2) takes " , prettytime (time (result)), " , " , prettymemory (memory (result)), " (GC " , prettytime (gctime (result)) , " )" )
30
37
end
@@ -45,15 +52,15 @@ for T ∈ [Int64, Float64]
45
52
maxnamelength = maximum (namelengths)
46
53
47
54
for m ∈ instances
48
- result = mean (@benchmark * ($ (copy (m)), $ (copy (m))))
55
+ result = mean (@benchmark mul ($ (copy (m)), $ (copy (m))))
49
56
padding = maxnamelength - length (string (typeof (m). name. name))
50
57
println (typeof (m). name. name, " :" , " " ^ padding, " m3 = m1 * m2 takes " , prettytime (time (result)), " , " , prettymemory (memory (result)), " (GC " , prettytime (gctime (result)) , " )" )
51
58
end
52
59
53
60
println ()
54
61
55
62
for m ∈ mutables
56
- result = mean (@benchmark A_mul_B ! ($ (copy (m)), $ (copy (m)), $ (copy (m))))
63
+ result = mean (@benchmark mul ! ($ (copy (m)), $ (copy (m)), $ (copy (m))))
57
64
padding = maxnamelength - length (string (typeof (m). name. name))
58
65
println (typeof (m). name. name, " :" , " " ^ padding, " A_mul_B!(m3, m1, m2) takes " , prettytime (time (result)), " , " , prettymemory (memory (result)), " (GC " , prettytime (gctime (result)) , " )" )
59
66
end
0 commit comments