diff --git a/reactor/Core/src/jetbrains/mps/logic/reactor/core/internal/ControllerImpl.kt b/reactor/Core/src/jetbrains/mps/logic/reactor/core/internal/ControllerImpl.kt index 1f46c67f..d7cc3250 100644 --- a/reactor/Core/src/jetbrains/mps/logic/reactor/core/internal/ControllerImpl.kt +++ b/reactor/Core/src/jetbrains/mps/logic/reactor/core/internal/ControllerImpl.kt @@ -96,9 +96,14 @@ internal class ControllerImpl ( state.processActivated(this, occ, NORMAL()) override fun offerMatch(match: RuleMatchEx, inStatus: FeedbackStatus) : FeedbackStatus = - inStatus.then { checkMatchPreconditions(match, it) } - .also { trace.trying(match) } - .then { processGuard(match, it) } + profiler.profile("offerMatch") { + + inStatus + .then { checkMatchPreconditions(match, it) } + .also { trace.trying(match) } + .then { processGuard(match, it) } + + } private fun checkMatchPreconditions(match: RuleMatchEx, inStatus: FeedbackStatus) : FeedbackStatus { val context = Context(inStatus, match.logicalContext(), match.rule().uniqueTag(), trace) diff --git a/reactor/Core/src/jetbrains/mps/logic/reactor/core/internal/ProcessingStateImpl.kt b/reactor/Core/src/jetbrains/mps/logic/reactor/core/internal/ProcessingStateImpl.kt index 9b644ce6..5783e380 100644 --- a/reactor/Core/src/jetbrains/mps/logic/reactor/core/internal/ProcessingStateImpl.kt +++ b/reactor/Core/src/jetbrains/mps/logic/reactor/core/internal/ProcessingStateImpl.kt @@ -229,7 +229,12 @@ internal class ProcessingStateImpl(private var dispatchingFront: Dispatcher.Disp trace.reactivate(active) } - this.dispatchingFront = dispatchingFront.expand(active) + + profiler.profile("dispatch_${active.constraint().symbol()}") { + + this.dispatchingFront = dispatchingFront.expand(active) + + } val matches = dispatchingFront.matches().toList() val newCurrentMatches = @@ -264,21 +269,41 @@ internal class ProcessingStateImpl(private var dispatchingFront: Dispatcher.Disp if (operational) action(this) else this private fun processMatch(controller: Controller, match: RuleMatchEx, inStatus: FeedbackStatus) : FeedbackStatus = - controller.offerMatch(match, inStatus) - .let { when (it) { - is FeedbackStatus.ABORTED -> { // guard is not satisfied - trace.reject(match) - return it.recover() // return from the enclosing method + profiler.profile("processMatch") { - } is FeedbackStatus.FAILED -> { // guard failed - return it.recover() // return from the enclosing method + controller.offerMatch(match, inStatus) + .let { + when (it) { + is FeedbackStatus.ABORTED -> { // guard is not satisfied + trace.reject(match) + return it.recover() // return from the enclosing method - } else -> it - } } - .also { trace.trigger(match) } - .also { accept(controller, match) } - .then { controller.processBody(match, it) } - .also { trace.finish(match) } + } + is FeedbackStatus.FAILED -> { // guard failed + return it.recover() // return from the enclosing method + + } + else -> it + } + } + .also { trace.trigger(match) } + .also { + profiler.profile("accept") { + + accept(controller, match) + + } + } + .then { + profiler.profile("processBody") { + + controller.processBody(match, it) + + } + } + .also { trace.finish(match) } + + } private fun accept(controller: Controller, match: RuleMatchEx) {