Change how profiler data is transferred from constraints reactor
This commit is contained in:
parent
83e273da73
commit
1b550cbd32
|
|
@ -137,6 +137,8 @@ internal class EvaluationSessionImpl private constructor (
|
|||
|
||||
var token: SessionToken? = null
|
||||
|
||||
var profiler: Profiler? = null
|
||||
|
||||
override fun withTrace(computingTracer: EvaluationTrace): EvaluationSession.Config {
|
||||
this.evaluationTrace = computingTracer
|
||||
return this
|
||||
|
|
@ -147,6 +149,11 @@ internal class EvaluationSessionImpl private constructor (
|
|||
return this
|
||||
}
|
||||
|
||||
override fun withProfiler(profiler: Profiler?): EvaluationSession.Config {
|
||||
this.profiler = profiler
|
||||
return this
|
||||
}
|
||||
|
||||
override fun withIncrSpec(ispec: IncrementalSpec): EvaluationSession.Config {
|
||||
return this
|
||||
}
|
||||
|
|
@ -160,11 +167,6 @@ internal class EvaluationSessionImpl private constructor (
|
|||
var session = Backend.ourBackend.ourSession.get()
|
||||
if (session != null) throw IllegalStateException("session already active")
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
val durations = parameters[ParameterKey.of("profiling.data", MutableMap::class.java)]
|
||||
as MutableMap<String, String>?
|
||||
val profiler = durations?.let { Profiler() }
|
||||
|
||||
session = EvaluationSessionImpl(program, supervisor, evaluationTrace, profiler, parameters)
|
||||
Backend.ourBackend.ourSession.set(session)
|
||||
try {
|
||||
|
|
@ -172,15 +174,6 @@ internal class EvaluationSessionImpl private constructor (
|
|||
return session.launch(token, main)
|
||||
}
|
||||
finally {
|
||||
try {
|
||||
profiler?.run {
|
||||
formattedData().entries.forEach { e -> durations.put(e.key, e.value) }
|
||||
clear()
|
||||
}
|
||||
}
|
||||
catch (t: Throwable) {
|
||||
// avoid nested failure
|
||||
}
|
||||
Backend.ourBackend.ourSession.set(null)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,6 +19,8 @@ package jetbrains.mps.logic.reactor.evaluation;
|
|||
|
||||
import jetbrains.mps.logic.reactor.program.IncrementalSpec;
|
||||
import jetbrains.mps.logic.reactor.program.Program;
|
||||
import jetbrains.mps.logic.reactor.util.Profiler;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
|
|
@ -80,6 +82,8 @@ public abstract class EvaluationSession {
|
|||
|
||||
public Config withSessionToken(SessionToken token) { return this; }
|
||||
|
||||
public Config withProfiler(Profiler profiler) { return this; }
|
||||
|
||||
@Deprecated(forRemoval = true)
|
||||
public Config withIncrSpec(IncrementalSpec ispec) { return this; }
|
||||
|
||||
|
|
|
|||
|
|
@ -72,16 +72,16 @@ class Profiler {
|
|||
|
||||
//sort in-place descending
|
||||
Collections.sort(parentName2Dur) { e1, e2 -> if (e2.value < e1.value) -1 else 1 }
|
||||
val sb = StringBuilder("time %1\$Ts.%1\$TLs (%2\$d times)".format(millis(data.dur), data.freq))
|
||||
val sb = StringBuilder("[time: %1\$Ts.%1\$TLs count: %2\$d]".format(millis(data.dur), data.freq))
|
||||
parentName2Dur
|
||||
.asSequence()
|
||||
.takeWhile { (_, dur) -> parentsToReport > 0 && millis(dur) > 0 }
|
||||
.forEach { (parentName, dur) ->
|
||||
parentsToReport -= millis(dur)
|
||||
|
||||
sb.append("\n -- ${parentName}")
|
||||
.append(" time %1\$Ts.%1\$TLs".format(millis(dur)))
|
||||
.append(" (%1\$d times)".format(data.parentFreqs[parentName] ?: 0)) }
|
||||
sb.append("\n \\-- ${parentName}")
|
||||
.append(" [time: %1\$Ts.%1\$TLs".format(millis(dur)))
|
||||
.append(" count: %1\$d]".format(data.parentFreqs[parentName] ?: 0)) }
|
||||
|
||||
name to sb.toString()
|
||||
}.toMap()
|
||||
|
|
|
|||
Loading…
Reference in New Issue