Skip to content

Commit 9d29678

Browse files
committed
[ConstraintSystem] ExpressionTimer: Make it possible to access remaining time until threshold
1 parent e60afb3 commit 9d29678

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

include/swift/Sema/ConstraintSystem.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,13 +199,19 @@ class ExpressionTimer {
199199
return endTime.getProcessTime() - StartTime.getProcessTime();
200200
}
201201

202+
/// Return the remaining process time in milliseconds until the
203+
/// threshold specified during construction is reached.
204+
unsigned getRemainingProcessTimeInMillis() const {
205+
auto elapsed = unsigned(getElapsedProcessTimeInFractionalSeconds());
206+
return elapsed >= ThresholdInMillis ? 0 : ThresholdInMillis - elapsed;
207+
}
208+
202209
// Disable emission of warnings about expressions that take longer
203210
// than the warning threshold.
204211
void disableWarning() { PrintWarning = false; }
205212

206213
bool isExpired() const {
207-
auto elapsed = getElapsedProcessTimeInFractionalSeconds();
208-
return unsigned(elapsed) > ThresholdInMillis;
214+
return getRemainingProcessTimeInMillis() == 0;
209215
}
210216
};
211217

0 commit comments

Comments
 (0)