Skip to content

Commit

Permalink
add array growth benchmarks (ref JuliaLang/julia#13977)
Browse files Browse the repository at this point in the history
  • Loading branch information
jrevels committed Jan 27, 2016
1 parent 46f262f commit 3213b48
Showing 1 changed file with 31 additions and 9 deletions.
40 changes: 31 additions & 9 deletions src/arrays/ArrayBenchmarks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ using ..BaseBenchmarks.samerand
# indexing #
############

# PR #10525 #
#-----------#
# #10525 #
#--------#

include("sumindex.jl")

Expand All @@ -32,8 +32,8 @@ include("sumindex.jl")
@tags "array" "sum" "indexing" "simd"
end

# Issue #10301 #
#--------------#
# #10301 #
#--------#

include("loadindex.jl")

Expand Down Expand Up @@ -91,12 +91,34 @@ include("cat.jl")
@tags "array" "indexing" "cat" "hcat" "vcat" "hvcat" "setindex"
end

#################
# comprehension #
#################
############################
# in-place growth (#13977) #
############################

function push_multiple!(collection, items)
for item in items
push!(collection, item)
end
return collection
end

@track BaseBenchmarks.TRACKER "array growth" begin
@setup begin
sizes = (8, 256, 2048)
vectors = map(samerand, sizes)
end
@benchmarks begin
[(:push_single!, length(v)) => push!(copy(v), samerand()) for v in vectors]
[(:push_multiple!, length(v)) => push_multiple!(copy(v), v) for v in vectors]
[(:append!, length(v)) => append!(copy(v), v) for v in vectors]
[(:prerend!, length(v)) => prepend!(copy(v), v) for v in vectors]
end
@tags "array" "growth" "push!" "append!" "prepend!"
end

# Issue #13401 #
#--------------#
##########################
# comprehension (#13401) #
##########################

perf_compr_collect(X) = [x for x in X]
perf_compr_iter(X) = [sin(x) + x^2 - 3 for x in X]
Expand Down

0 comments on commit 3213b48

Please sign in to comment.