Skip to content

Commit

Permalink
Update performance tests
Browse files Browse the repository at this point in the history
  • Loading branch information
IainNZ committed May 7, 2016
1 parent d3b46de commit 9cae9af
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 60 deletions.
20 changes: 0 additions & 20 deletions test/perf/JuMPArray-iteration.jl

This file was deleted.

5 changes: 2 additions & 3 deletions test/perf/indvec.jl
Expand Up @@ -14,9 +14,8 @@ function bench_add(n)
end

bench_add(10)
gc_disable()
gc_enable(false)
@time bench_add(1000000)
@time bench_add(1000000)
@time bench_add(1000000)
gc_enable()

gc_enable(true)
12 changes: 6 additions & 6 deletions test/perf/macro.jl
Expand Up @@ -4,8 +4,8 @@ using JuMP

function test_linear(N)
m = Model()
@defVar(m, x[1:10N,1:5N])
@defVar(m, y[1:N,1:N,1:N])
@variable(m, x[1:10N,1:5N])
@variable(m, y[1:N,1:N,1:N])

for z in 1:10
@constraint(m,
Expand All @@ -24,8 +24,8 @@ end

function test_quad(N)
m = Model()
@defVar(m, x[1:10N,1:5N])
@defVar(m, y[1:N,1:N,1:N])
@variable(m, x[1:10N,1:5N])
@variable(m, y[1:N,1:N,1:N])

for z in 1:10
@constraint(m,
Expand All @@ -49,8 +49,8 @@ test_linear(1)
test_quad(1)
for N in [20,50,100]
println(" Running N=$(N)...")
N1_times = {}
N2_times = {}
N1_times = Any[]
N2_times = Any[]
for iter in 1:10
tic()
test_linear(N)
Expand Down
2 changes: 1 addition & 1 deletion test/perf/norms.jl
Expand Up @@ -2,7 +2,7 @@ using JuMP

function norm_stress1(N)
m = Model()
@defVar(m, x[1:N])
@variable(m, x[1:N])
for i in 1:N
@constraint(m, norm2{x[j],j=1:i} <= i)
end
Expand Down
13 changes: 6 additions & 7 deletions test/perf/speed.jl
Expand Up @@ -58,13 +58,13 @@ function pMedian(numFacility::Int,numCustomer::Int,numLocation::Int,useMPS)
m = Model()

# Facility locations
@defVar(m, 0 <= s[1:numLocation] <= 1)
@variable(m, 0 <= s[1:numLocation] <= 1)

# Aux. variable: x_a,i = 1 iff the closest facility to a is at i
@defVar(m, 0 <= x[1:numLocation,1:numCustomer] <= 1)
@variable(m, 0 <= x[1:numLocation,1:numCustomer] <= 1)

# Objective: min distance
@setObjective(m, Max, sum{abs(customerLocations[a]-i)*x[i,a], a = 1:numCustomer, i = 1:numLocation} )
@objective(m, Max, sum{abs(customerLocations[a]-i)*x[i,a], a = 1:numCustomer, i = 1:numLocation} )

# Constraints
for a in 1:numCustomer
Expand Down Expand Up @@ -104,9 +104,9 @@ function cont5(n,useMPS)

tic()
mod = Model()
@defVar(mod, 0 <= y[0:m,0:n] <= 1)
@defVar(mod, -1 <= u[1:m] <= 1)
@setObjective(mod, Min, y[0,0])
@variable(mod, 0 <= y[0:m,0:n] <= 1)
@variable(mod, -1 <= u[1:m] <= 1)
@objective(mod, Min, y[0,0])

# PDE
for i = 0:m1
Expand Down Expand Up @@ -169,4 +169,3 @@ function RunTests()
end

RunTests()

12 changes: 6 additions & 6 deletions test/perf/speed2.jl
Expand Up @@ -19,13 +19,13 @@ function pMedian(numFacility::Int,numCustomer::Int,numLocation::Int)
m = Model()

# Facility locations
@defVar(m, 0 <= s[1:numLocation] <= 1)
@variable(m, 0 <= s[1:numLocation] <= 1)

# Aux. variable: x_a,i = 1 iff the closest facility to a is at i
@defVar(m, 0 <= x[1:numLocation,1:numCustomer] <= 1)
@variable(m, 0 <= x[1:numLocation,1:numCustomer] <= 1)

# Objective: min distance
@setObjective(m, Max, sum{abs(customerLocations[a]-i)*x[i,a], a = 1:numCustomer, i = 1:numLocation} )
@objective(m, Max, sum{abs(customerLocations[a]-i)*x[i,a], a = 1:numCustomer, i = 1:numLocation} )

# Constraints
for a in 1:numCustomer
Expand Down Expand Up @@ -61,9 +61,9 @@ function cont5(n)

tic()
mod = Model()
@defVar(mod, 0 <= y[0:m,0:n] <= 1)
@defVar(mod, -1 <= u[1:m] <= 1)
@setObjective(mod, Min, 0.25*dx*( (y[m,0] - yt[1])^2 +
@variable(mod, 0 <= y[0:m,0:n] <= 1)
@variable(mod, -1 <= u[1:m] <= 1)
@objective(mod, Min, 0.25*dx*( (y[m,0] - yt[1])^2 +
2*sum{ (y[m,j]-yt[j+1])^2, j=1:n1} + (y[m,n]-yt[n+1])^2) +
0.25*a*dt*(2*sum{u[i]^2,i=1:m1} + u[m]^2))

Expand Down
16 changes: 8 additions & 8 deletions test/perf/timetoprint.jl
Expand Up @@ -9,7 +9,7 @@ run(`$(ENV["_"]) -e """
using JuMP
m = Model()
N = 100
@defVar(m, x[1:N])
@variable(m, x[1:N])
@constraint(m, sum{i*x[i],i=1:N} >= N)
@time JuMP.aff_str(JuMP.REPLMode, m.linconstr[end].terms)
@time JuMP.model_str(JuMP.REPLMode, m)"""
Expand All @@ -23,7 +23,7 @@ run(`$(ENV["_"]) -e """
using JuMP
m = Model()
N = 100
@defVar(m, x[1:N])
@variable(m, x[1:N])
@constraint(m, sum{i*x[i],i=1:N} >= N)
@time JuMP.model_str(JuMP.REPLMode, m)"""
`)
Expand All @@ -36,7 +36,7 @@ run(`$(ENV["_"]) -e """
using JuMP
m = Model()
N = 10000
@defVar(m, x[1:N])
@variable(m, x[1:N])
@constraint(m, sum{i*x[i],i=1:N} >= N)
@time sprint(print, m)"""
`)
Expand All @@ -49,11 +49,11 @@ run(`$(ENV["_"]) -e """
using JuMP
m = Model()
N = 10
@defVar(m, x1[1:N])
@defVar(m, x2[1:N,f=1:N])
@defVar(m, x3[1:N,f=1:2:N])
@defVar(m, x4[[:a,:b,:c]])
@defVar(m, x5[[:a,:b,:c],[:d,"e",4]])
@variable(m, x1[1:N])
@variable(m, x2[1:N,f=1:N])
@variable(m, x3[1:N,f=1:2:N])
@variable(m, x4[[:a,:b,:c]])
@variable(m, x5[[:a,:b,:c],[:d,"e",4]])
@constraint(m,
sum{i*x1[i],i=1:N} +
sum{i*f*x2[i,f],i=1:N,f=1:N} +
Expand Down
18 changes: 9 additions & 9 deletions test/perf/vector_speedtest.jl
Expand Up @@ -3,11 +3,11 @@ using JuMP
function test(n::Int)
m = Model()
a = rand(n,n)
@defVar(m,x[1:n,1:n])
@variable(m,x[1:n,1:n])
b = rand(n,n,n)
@defVar(m,y[1:n,1:n,1:n])
@variable(m,y[1:n,1:n,1:n])
c = rand(n)
@defVar(m,z[1:n])
@variable(m,z[1:n])

#initialize
@constraint(m,sum{c[i]*z[i],i=1:n}<=0)
Expand All @@ -17,24 +17,24 @@ function test(n::Int)
@constraint(m,sum{c[i]*z[i],i=1:n}<=1)
println("Vector with sum{}: $(toq())")
tic()
@constraint(m,dot(c,z) <= 1)
println("Vector with dot() : $(toq())")
@constraint(m,vecdot(c,z) <= 1)
println("Vector with vecdot() : $(toq())")

#2D Matrix
tic()
@constraint(m,sum{a[i,j]*x[i,j],i=1:n,j=1:n}<=1)
println("2D Matrix with sum{}: $(toq())")
tic()
@constraint(m,dot(a,x)<=1)
println("2D Matrix with bigdot(): $(toq())")
@constraint(m,vecdot(a,x)<=1)
println("2D Matrix with bigvecdot(): $(toq())")

#3D Matrix
tic()
@constraint(m,sum{b[i,j,k]*y[i,j,k],i=1:n,j=1:n,k=1:n}<=1)
println("3D Matrix with sum{}: $(toq())")
tic()
@constraint(m,dot(b,y)<=1)
println("3D Matrix with dot(): $(toq())")
@constraint(m,vecdot(b,y)<=1)
println("3D Matrix with vecdot(): $(toq())")
return 0
end

Expand Down

0 comments on commit 9cae9af

Please sign in to comment.