Skip to content

Commit

Permalink
add Array{Bool}/BitArray benchmarks (ref JuliaLang/julia#13946)
Browse files Browse the repository at this point in the history
  • Loading branch information
jrevels committed Jan 27, 2016
1 parent 3213b48 commit 739fd49
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 3 deletions.
41 changes: 38 additions & 3 deletions src/arrays/ArrayBenchmarks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,17 @@ end
# #10301 #
#--------#

include("loadindex.jl")
include("revloadindex.jl")

@track BaseBenchmarks.TRACKER "array index load" begin
@track BaseBenchmarks.TRACKER "array index load reverse" begin
@setup n = 10^6
@benchmarks begin
(:rev_load_slow!,) => perf_rev_load_slow!(samerand(n))
(:rev_load_fast!,) => perf_rev_load_fast!(samerand(n))
(:rev_loadmul_slow!,) => perf_rev_loadmul_slow!(samerand(n), samerand(n))
(:rev_loadmul_fast!,) => perf_rev_loadmul_fast!(samerand(n), samerand(n))
end
@tags "array" "load" "indexing" "reverse"
@tags "array" "indexing" "load" "reverse"
end

###############################
Expand Down Expand Up @@ -141,4 +141,39 @@ perf_compr_index(X) = [sin(X[i]) + (X[i])^2 - 3 for i in eachindex(X)]
@tags "array" "comprehension" "iteration" "indexing" "linspace" "collect" "range"
end

###############################
# BoolArray/BitArray (#13946) #
###############################

function perf_bool_load!(result, a, b)
for i in eachindex(result)
result[i] = a[i] != b
end
return result
end

function perf_true_load!(result)
for i in eachindex(result)
result[i] = true
end
return result
end

@track BaseBenchmarks.TRACKER "array bool" begin
@setup begin
n, range = 10^6, -3:3
a, b = samerand(range, n), samerand(range)
boolarr, bitarr = Vector{Bool}(n), BitArray(n)
end
@benchmarks begin
(:bitarray_bool_load!,) => perf_bool_load!(bitarr, a, b)
(:boolarray_bool_load!,) => perf_bool_load!(boolarr, a, b)
(:bitarray_true_load!,) => perf_true_load!(bitarr)
(:boolarray_true_load!,) => perf_true_load!(boolarr)
(:bitarray_true_fill!,) => fill!(bitarr, true)
(:boolarray_true_fill!,) => fill!(boolarr, true)
end
@tags "array" "indexing" "load" "bool" "bitarray" "fill!"
end

end # module
File renamed without changes.

0 comments on commit 739fd49

Please sign in to comment.