Skip to content

Commit 8d612de

Browse files
committed
Add a >0.1s timer to trace
1 parent 3458da7 commit 8d612de

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

compiler/src/dotty/tools/dotc/reporting/trace.scala

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ trait TraceSyntax:
9696
(op: => T)(using Context): T =
9797
if ctx.mode.is(Mode.Printing) || !isForced && (printer eq Printers.noPrinter) then op
9898
else
99+
val start = System.nanoTime
99100
// Avoid evaluating question multiple time, since each evaluation
100101
// may cause some extra logging output.
101102
val q = question
@@ -109,7 +110,13 @@ trait TraceSyntax:
109110
def finalize(msg: String) =
110111
if !finalized then
111112
ctx.base.indent -= 1
112-
doLog(s"$margin$msg")
113+
val stop = System.nanoTime
114+
val diffNs = stop - start
115+
val diffS = (diffNs / 1000 / 1000).toInt / 1000.0
116+
if diffS > 0.1 then
117+
doLog(s"$margin$msg (${"%.2f".format(diffS)} s)")
118+
else
119+
doLog(s"$margin$msg")
113120
finalized = true
114121
try
115122
doLog(s"$margin$leading")

compiler/src/dotty/tools/dotc/typer/ImportSuggestions.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ trait ImportSuggestions:
264264
end importSuggestions
265265

266266
/** Reduce next timeout for import suggestions by the amount of time it took
267-
* for current search, but but never less than to half of the previous budget.
267+
* for current search, but never less than to half of the previous budget.
268268
*/
269269
private def reduceTimeBudget(used: Int)(using Context) =
270270
val run = ctx.run.nn

0 commit comments

Comments
 (0)