Skip to content

Commit

Permalink
update prof (#229)
Browse files Browse the repository at this point in the history
  • Loading branch information
PierreMartinon authored Aug 29, 2024
1 parent 6dfff6f commit 2be6242
Showing 1 changed file with 11 additions and 21 deletions.
32 changes: 11 additions & 21 deletions benchmark/prof.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ using JET

precompile = true

test_time = true
test_solve = true
#test = :objective
test = :constraints
test_code_warntype = false
Expand All @@ -23,28 +23,18 @@ grid_size = 100
docp, nlp = direct_transcription(ocp, grid_size = grid_size)
println("Load problem ", prob[:name])

# full solve
if test_time
if precompile
println("Precompilation")
direct_solve(ocp, grid_size = grid_size, display = false, max_iter = 2)
end
println("Timed solve")
@timev sol = direct_solve(ocp, grid_size = grid_size, display = false)
@btime sol = direct_solve(ocp, grid_size = grid_size, display = false)
end

if precompile
println("Precompilation")
if test == :objective
CTDirect.DOCP_objective(CTDirect.DOCP_initial_guess(docp), docp)
else
CTDirect.DOCP_constraints!(
zeros(docp.dim_NLP_constraints),
CTDirect.DOCP_initial_guess(docp),
docp,
)
end
direct_solve(ocp, grid_size = grid_size, display = false, max_iter = 2)
CTDirect.DOCP_objective(CTDirect.DOCP_initial_guess(docp), docp)
CTDirect.DOCP_constraints!(zeros(docp.dim_NLP_constraints), CTDirect.DOCP_initial_guess(docp), docp)
end

# full solve
if test_solve
println("Timed solve")
@timev sol = direct_solve(ocp, grid_size = grid_size, display=false)
@btime sol = direct_solve(ocp, grid_size = grid_size, display=false)
end

if test_code_warntype
Expand Down

0 comments on commit 2be6242

Please sign in to comment.