Skip to content

Instantly share code, notes, and snippets.

@chezou
Last active August 29, 2015 14:10
Show Gist options
  • Select an option

  • Save chezou/05c8d03be11b006a896e to your computer and use it in GitHub Desktop.

Select an option

Save chezou/05c8d03be11b006a896e to your computer and use it in GitHub Desktop.
Julia Dict() execution time
dict = Dict()
@time for i in [1:10000000]
dict[i] = 1
end
# elapsed time: 22.824151615 seconds (2413509808 bytes allocated, 9.20% gc time)
dict = Dict()
@time for i in [1:10000]
dict[i] = 1
end
# elapsed time: 0.006612668 seconds (1248832 bytes allocated)
dict = Dict{Int, Int}()
@time for i in [1:10000000]
dict[i] = 1
end
# elapsed time: 3.033477899 seconds (807448656 bytes allocated, 2.43% gc time)
dict = Dict{Int, Int}()
@time for i in [1:10000]
dict[i] = 1
end
# elapsed time: 0.000807427 seconds (604368 bytes allocated)
$ ruby -v
ruby 2.1.0p0 (2013-12-25 revision 44422) [x86_64-darwin13.0]
$ julia --version
julia version 0.4.0-dev+1752
require 'benchmark'
hash = {}
Benchmark.bmbm do |x|
x.report { 10000000.times{|i| hash[i] = 1 } }
end
#Rehearsal ------------------------------------
# 9.100000 0.430000 9.530000 ( 10.012342)
#--------------------------- total: 9.530000sec
#
# user system total real
# 5.290000 0.060000 5.350000 ( 5.509731)
hash = {}
Benchmark.bmbm do |x|
x.report { 10000.times{|i| hash[i] = 1 } }
end
#Rehearsal ------------------------------------
# 0.010000 0.000000 0.010000 ( 0.003642)
#--------------------------- total: 0.010000sec
#
# user system total real
# 0.000000 0.000000 0.000000 ( 0.002021)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment