Skip to content

Commit 8a91e05

Browse files
authored
Report compilation stats when silent_solver=false (#633)
1 parent 584e050 commit 8a91e05

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

src/solution.jl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,11 @@ function solve!(
8585
if problem_vexity(p) in (ConcaveVexity(), NotDcp())
8686
throw(DCPViolationError())
8787
end
88-
context = Context(p, optimizer_factory)
88+
context, (stats...) = @timed Context(p, optimizer_factory)
89+
if !silent_solver
90+
s = round(stats.time; digits = 2), Base.format_bytes(stats.bytes)
91+
@info "[Convex.jl] Compilation finished: $(s[1]) seconds, $(s[2]) of memory allocated"
92+
end
8993
if silent_solver
9094
MOI.set(context.model, MOI.Silent(), true)
9195
end

test/test_constraints.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ end
3838

3939
function test_EqualToConstraint_violated()
4040
p = satisfy([constant(5) == 0])
41-
@test_logs (:warn,) solve!(p, SCS.Optimizer)
41+
@test_logs (:info,) (:warn,) solve!(p, SCS.Optimizer)
4242
return
4343
end
4444

@@ -96,7 +96,7 @@ end
9696

9797
function test_GreaterThanConstraint_violated()
9898
p = satisfy([constant(5) >= 6])
99-
@test_logs (:warn,) solve!(p, SCS.Optimizer)
99+
@test_logs (:info,) (:warn,) solve!(p, SCS.Optimizer)
100100
return
101101
end
102102

@@ -145,7 +145,7 @@ end
145145

146146
function test_LessThanConstraint_violated()
147147
p = satisfy([constant(5) <= 4])
148-
@test_logs (:warn,) solve!(p, SCS.Optimizer)
148+
@test_logs (:info,) (:warn,) solve!(p, SCS.Optimizer)
149149
return
150150
end
151151

@@ -199,10 +199,10 @@ end
199199
function test_GenericConstraint_PositiveSemidefiniteConeSquare_violated()
200200
X = constant([1 2; 3 4])
201201
p = satisfy([X 0])
202-
@test_logs (:warn,) solve!(p, SCS.Optimizer)
202+
@test_logs (:info,) (:warn,) solve!(p, SCS.Optimizer)
203203
X = constant([1 2; 2 3])
204204
p = satisfy([X 0])
205-
@test_logs (:warn,) solve!(p, SCS.Optimizer)
205+
@test_logs (:info,) (:warn,) solve!(p, SCS.Optimizer)
206206
return
207207
end
208208

0 commit comments

Comments
 (0)