Skip to content

Commit 9541cac

Browse files
authored
Merge pull request #34 from JuliaCI/reductions
add some reduction benchmarks to array suite
2 parents 9726c60 + 0d1a44c commit 9541cac

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/array/ArrayBenchmarks.jl

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,25 @@ import Compat: UTF8String, view
1010

1111
const SUITE = BenchmarkGroup()
1212

13+
#############################################################################
14+
# basic array-math reduction-like functions
15+
16+
afloat = samerand(10^3)
17+
aint = samerand(Int, 10^3)
18+
acomplex = samerand(Complex{Float64}, 10^3)
19+
g = addgroup!(SUITE, "reductions", ["sum", "array", "reduce"])
20+
norm1(x) = norm(x, 1)
21+
norminf(x) = norm(x, Inf)
22+
perf_reduce(x) = reduce((x,y) -> x + 2y, real(zero(eltype(x))), x)
23+
perf_mapreduce(x) = mapreduce(x -> real(x)+imag(x), (x,y) -> x + 2y, real(zero(eltype(x))), x)
24+
for a in (afloat, aint)
25+
for fun in (sum, sumabs, sumabs2, norm, norm1, norminf, mean, var, maxabs, perf_reduce, perf_mapreduce)
26+
g[string(fun), string(eltype(a))] = @benchmarkable $fun($a)
27+
end
28+
end
29+
30+
#############################################################################
31+
1332
############
1433
# indexing #
1534
############

0 commit comments

Comments
 (0)