-
-
Save joehuchette/00e7921f065192a4a1c2 to your computer and use it in GitHub Desktop.
GC/JuMP benchmark
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using JuMP | |
function pMedian_macro(M::Int,N::Int) | |
srand(10) | |
c = [rand(1:M) for a = 1:N ] | |
m = Model() | |
# Aux. variable: x_a,i = 1 iff the closest facility to a is at i | |
@defVar(m, 0 <= x[1:M,1:N] <= 1) | |
tic() | |
# Objective: min distance | |
@time @defExpr( 1 + sum{abs(c[j]-i)*x[i,j]*x[1,j], i = 1:M, j = 1:N}) | |
buildTime = toq() | |
return buildTime | |
end | |
function pMedian_function(M::Int,N::Int) | |
srand(10) | |
c = [rand(1:M) for a = 1:N ] | |
m = Model() | |
# Aux. variable: x_a,i = 1 iff the closest facility to a is at i | |
@defVar(m, 0 <= x[1:M,1:N] <= 1) | |
tic() | |
# Objective: min distance | |
@time(begin | |
aff = QuadExpr() | |
aff += 1 | |
for i in 1:M, j in 1:N | |
aff += abs(c[j]-i)*(1-x[i,j])*x[1,j] | |
end | |
end) | |
buildTime = toq() | |
return buildTime | |
end | |
function RunTests(M::Int,N::Int,nTrials::Int) | |
# Pmedian | |
pmedian_macro = Float64[] | |
pmedian_funct = Float64[] | |
for runs = 1:nTrials | |
#btm = pMedian_macro(M,N) | |
btf = pMedian_function(M,N) | |
#push!(pmedian_macro, btm) | |
push!(pmedian_funct, btf) | |
end | |
#sort!(pmedian_macro) | |
sort!(pmedian_funct) | |
#println("PMEDIAN MACRO MIN=",minimum(pmedian_macro)," MED=",pmedian_macro[iround(nTrials/2)]) | |
println("PMEDIAN FUNCT MIN=",minimum(pmedian_funct)," MED=",pmedian_funct[iround(nTrials/2)]) | |
end | |
#RunTests(10,10,1) | |
RunTests(50,50,9) | |
RunTests(100,100,9) | |
RunTests(200,200,9) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ julia speed.jl [9:57:54] | |
WARNING: deprecated syntax "{}" at /Users/huchette/.julia/v0.4/Calculus/src/symbolic.jl:108. | |
Use "[]" instead. | |
WARNING: deprecated syntax "{}" at /Users/huchette/.julia/v0.4/Calculus/src/symbolic.jl:121. | |
Use "[]" instead. | |
WARNING: deprecated syntax "{a,b, ...}" at /Users/huchette/.julia/v0.4/Calculus/src/differentiate.jl:41. | |
Use "Any[a,b, ...]" instead. | |
WARNING: deprecated syntax "{a,b, ...}" at /Users/huchette/.julia/v0.4/Calculus/src/differentiate.jl:58. | |
Use "Any[a,b, ...]" instead. | |
WARNING: deprecated syntax "{a=>b, ...}" at /Users/huchette/.julia/v0.4/Calculus/src/deparse.jl:1. | |
Use "Dict{Any,Any}(a=>b, ...)" instead. | |
WARNING: deprecated syntax "[a=>b, ...]" at /Users/huchette/.julia/v0.4/JuMP/src/callbacks.jl:77. | |
Use "Dict(a=>b, ...)" instead. | |
elapsed time: 0.034888357 seconds (121 MB allocated, 37.20% gc time in 22 pauses with 0 full sweep) | |
elapsed time: 0.035672305 seconds (121 MB allocated, 36.22% gc time in 22 pauses with 0 full sweep) | |
elapsed time: 0.029222681 seconds (121 MB allocated, 39.73% gc time in 22 pauses with 0 full sweep) | |
elapsed time: 0.031431412 seconds (121 MB allocated, 39.74% gc time in 22 pauses with 0 full sweep) | |
elapsed time: 0.052672779 seconds (121 MB allocated, 65.65% gc time in 23 pauses with 1 full sweep) | |
elapsed time: 0.031385049 seconds (121 MB allocated, 38.17% gc time in 22 pauses with 0 full sweep) | |
elapsed time: 0.031106552 seconds (121 MB allocated, 38.27% gc time in 22 pauses with 0 full sweep) | |
elapsed time: 0.029077565 seconds (121 MB allocated, 38.30% gc time in 22 pauses with 0 full sweep) | |
elapsed time: 0.031447343 seconds (121 MB allocated, 39.92% gc time in 23 pauses with 0 full sweep) | |
WARNING: iround(x) is deprecated, use round(Integer,x) instead. | |
in RunTests at /Users/huchette/Dropbox/research/JuMP/SIREVBenchmarks/macros/speed.jl:56 | |
in include at ./boot.jl:242 | |
in include_from_node1 at loading.jl:128 | |
in process_options at ./client.jl:300 | |
in _start at ./client.jl:382 | |
in _start at /usr/local/julia/usr/lib/julia/sys.dylib | |
PMEDIAN FUNCT MIN=0.029255282 MED=0.031619167 | |
elapsed time: 0.491643578 seconds (1910 MB allocated, 48.13% gc time in 348 pauses with 3 full sweep) | |
elapsed time: 0.485905886 seconds (1910 MB allocated, 48.14% gc time in 348 pauses with 3 full sweep) | |
elapsed time: 0.474326456 seconds (1910 MB allocated, 46.10% gc time in 348 pauses with 2 full sweep) | |
elapsed time: 0.488310956 seconds (1910 MB allocated, 48.21% gc time in 348 pauses with 3 full sweep) | |
elapsed time: 0.500107032 seconds (1910 MB allocated, 49.29% gc time in 348 pauses with 3 full sweep) | |
elapsed time: 0.490969172 seconds (1910 MB allocated, 48.16% gc time in 348 pauses with 3 full sweep) | |
elapsed time: 0.467269198 seconds (1910 MB allocated, 46.43% gc time in 348 pauses with 2 full sweep) | |
elapsed time: 0.493098595 seconds (1910 MB allocated, 48.73% gc time in 348 pauses with 3 full sweep) | |
elapsed time: 0.493117882 seconds (1910 MB allocated, 48.34% gc time in 348 pauses with 3 full sweep) | |
WARNING: iround(x) is deprecated, use round(Integer,x) instead. | |
in RunTests at /Users/huchette/Dropbox/research/JuMP/SIREVBenchmarks/macros/speed.jl:56 | |
in include at ./boot.jl:242 | |
in include_from_node1 at loading.jl:128 | |
in process_options at ./client.jl:300 | |
in _start at ./client.jl:382 | |
in _start at /usr/local/julia/usr/lib/julia/sys.dylib | |
PMEDIAN FUNCT MIN=0.467416097 MED=0.491105973 | |
elapsed time: 15.255029726 seconds (30501 MB allocated, 37.16% gc time in 5468 pauses with 43 full sweep) | |
elapsed time: 14.038366067 seconds (30501 MB allocated, 36.87% gc time in 5468 pauses with 43 full sweep) | |
elapsed time: 15.108217298 seconds (30501 MB allocated, 36.87% gc time in 5468 pauses with 43 full sweep) | |
elapsed time: 16.14594 seconds (30501 MB allocated, 36.86% gc time in 5468 pauses with 43 full sweep) | |
elapsed time: 16.70766917 seconds (30501 MB allocated, 37.27% gc time in 5468 pauses with 43 full sweep) | |
elapsed time: 16.834051944 seconds (30501 MB allocated, 36.55% gc time in 5468 pauses with 43 full sweep) | |
elapsed time: 15.614372039 seconds (30501 MB allocated, 37.03% gc time in 5468 pauses with 43 full sweep) | |
elapsed time: 16.281786066 seconds (30501 MB allocated, 36.22% gc time in 5468 pauses with 43 full sweep) | |
elapsed time: 15.742759113 seconds (30501 MB allocated, 36.49% gc time in 5468 pauses with 43 full sweep) | |
WARNING: iround(x) is deprecated, use round(Integer,x) instead. | |
in RunTests at /Users/huchette/Dropbox/research/JuMP/SIREVBenchmarks/macros/speed.jl:56 | |
in include at ./boot.jl:242 | |
in include_from_node1 at loading.jl:128 | |
in process_options at ./client.jl:300 | |
in _start at ./client.jl:382 | |
in _start at /usr/local/julia/usr/lib/julia/sys.dylib | |
PMEDIAN FUNCT MIN=14.038504761 MED=15.742959161 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
elapsed time: 0.109388498 seconds (127086544 bytes allocated, 68.30% gc time) | |
elapsed time: 0.104619756 seconds (127086544 bytes allocated, 69.80% gc time) | |
elapsed time: 0.112473157 seconds (127086544 bytes allocated, 70.83% gc time) | |
elapsed time: 0.083534158 seconds (127086544 bytes allocated, 60.86% gc time) | |
elapsed time: 0.108880065 seconds (127086544 bytes allocated, 69.26% gc time) | |
elapsed time: 0.107515262 seconds (127086544 bytes allocated, 70.18% gc time) | |
elapsed time: 0.117767153 seconds (127086544 bytes allocated, 69.46% gc time) | |
elapsed time: 0.189891717 seconds (127086544 bytes allocated, 64.47% gc time) | |
elapsed time: 0.088180171 seconds (127086544 bytes allocated, 62.10% gc time) | |
WARNING: iround(x) is deprecated, use round(Integer,x) instead. | |
in RunTests at /Users/huchette/Dropbox/research/JuMP/SIREVBenchmarks/macros/speed.jl:56 | |
in include at ./boot.jl:242 | |
in include_from_node1 at loading.jl:128 | |
in process_options at ./client.jl:300 | |
in _start at ./client.jl:382 | |
in _start at /usr/local/julia/usr/lib/julia/sys.dylib | |
PMEDIAN FUNCT MIN=0.083669503 MED=0.109025356 | |
elapsed time: 2.176847213 seconds (2003231024 bytes allocated, 72.60% gc time) | |
elapsed time: 2.312115818 seconds (2003231024 bytes allocated, 68.73% gc time) | |
elapsed time: 2.496390834 seconds (2003231024 bytes allocated, 73.33% gc time) | |
elapsed time: 1.754201579 seconds (2003231024 bytes allocated, 69.79% gc time) | |
elapsed time: 2.641958424 seconds (2003231024 bytes allocated, 67.39% gc time) | |
elapsed time: 2.410063638 seconds (2003231024 bytes allocated, 70.54% gc time) | |
elapsed time: 1.768498076 seconds (2003231024 bytes allocated, 69.26% gc time) | |
elapsed time: 2.588990123 seconds (2003231024 bytes allocated, 76.27% gc time) | |
elapsed time: 3.258643724 seconds (2003231024 bytes allocated, 71.16% gc time) | |
WARNING: iround(x) is deprecated, use round(Integer,x) instead. | |
in RunTests at /Users/huchette/Dropbox/research/JuMP/SIREVBenchmarks/macros/speed.jl:56 | |
in include at ./boot.jl:242 | |
in include_from_node1 at loading.jl:128 | |
in process_options at ./client.jl:300 | |
in _start at ./client.jl:382 | |
in _start at /usr/local/julia/usr/lib/julia/sys.dylib | |
PMEDIAN FUNCT MIN=1.754365165 MED=2.410215741 | |
elapsed time: 40.166397939 seconds (31983850800 bytes allocated, 53.09% gc time) | |
elapsed time: 35.590804598 seconds (31983850800 bytes allocated, 50.70% gc time) | |
elapsed time: 40.699396097 seconds (31983850800 bytes allocated, 51.60% gc time) | |
elapsed time: 35.695380145 seconds (31983850800 bytes allocated, 51.48% gc time) | |
elapsed time: 33.370379712 seconds (31983850800 bytes allocated, 51.23% gc time) | |
elapsed time: 32.793177478 seconds (31983850800 bytes allocated, 51.87% gc time) | |
elapsed time: 32.287439465 seconds (31983850800 bytes allocated, 51.56% gc time) | |
elapsed time: 33.701342032 seconds (31983850800 bytes allocated, 51.09% gc time) | |
elapsed time: 35.144313962 seconds (31983850800 bytes allocated, 50.68% gc time) | |
WARNING: iround(x) is deprecated, use round(Integer,x) instead. | |
in RunTests at /Users/huchette/Dropbox/research/JuMP/SIREVBenchmarks/macros/speed.jl:56 | |
in include at ./boot.jl:242 | |
in include_from_node1 at loading.jl:128 | |
in process_options at ./client.jl:300 | |
in _start at ./client.jl:382 | |
in _start at /usr/local/julia/usr/lib/julia/sys.dylib | |
PMEDIAN FUNCT MIN=32.287547632 MED=35.14443001 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment