diff --git a/ets2panda/compiler/core/compileJob.cpp b/ets2panda/compiler/core/compileJob.cpp index 1c1bbcea20c859430a09615526333f39c8b6e0ee..df51835bae9f67f0e6d19ee02a25fc9e8da278f7 100644 --- a/ets2panda/compiler/core/compileJob.cpp +++ b/ets2panda/compiler/core/compileJob.cpp @@ -20,6 +20,8 @@ namespace ark::es2panda::compiler { void CompileJob::Run() { + ES2PANDA_PERF_FN_SCOPE(); + std::unique_lock lock(m_); cond_.wait(lock, [this] { return dependencies_ == 0; }); diff --git a/ets2panda/compiler/lowering/phase.cpp b/ets2panda/compiler/lowering/phase.cpp index 47a89ade9ea2b820e11e190bceda1dd19e01aed6..5da4ace096ee411d9c6e94ff63f1a668924edf8e 100644 --- a/ets2panda/compiler/lowering/phase.cpp +++ b/ets2panda/compiler/lowering/phase.cpp @@ -230,6 +230,8 @@ bool Phase::Apply(public_lib::Context *ctx, parser::Program *program) SetPhaseManager(ctx->phaseManager); GetPhaseManager()->SetCurrentPhaseId(id_); + ES2PANDA_PERF_EVENT_SCOPE("@lowering-phase/" + std::string(Name())); + #ifndef NDEBUG if (!Precondition(ctx, program)) { ctx->GetChecker()->LogError(diagnostic::PRECOND_FAILED, {Name()}, lexer::SourcePosition {}); diff --git a/ets2panda/parser/parserImpl.cpp b/ets2panda/parser/parserImpl.cpp index a96e0eabc0c24a277eca86cb4321ee72c33375be..831b4b077c2264da3822879222e4db2788dfc550 100644 --- a/ets2panda/parser/parserImpl.cpp +++ b/ets2panda/parser/parserImpl.cpp @@ -74,6 +74,8 @@ void ParserImpl::ParseScript(const SourceFile &sourceFile, bool genStdLib) void ParserImpl::ParseProgram(ScriptKind kind) { + ES2PANDA_PERF_FN_SCOPE(); + lexer::SourcePosition startLoc = lexer_->GetToken().Start(); lexer_->NextToken(); program_->SetKind(kind); diff --git a/ets2panda/public/es2panda_lib.cpp b/ets2panda/public/es2panda_lib.cpp index 81b369462330b35829cc53c73e1945778f69c393..841ca3192dc63f6c6ab43ee5195b599964f5013d 100644 --- a/ets2panda/public/es2panda_lib.cpp +++ b/ets2panda/public/es2panda_lib.cpp @@ -741,6 +741,9 @@ extern "C" __attribute__((unused)) es2panda_Context *ProceedToState(es2panda_Con ctx->state = ES2PANDA_STATE_ERROR; break; } + if (ctx->config->options->IsDumpPerfMetrics()) { + util::DumpPerfMetrics(); + } return reinterpret_cast(ctx); } diff --git a/ets2panda/util/perfMetrics.cpp b/ets2panda/util/perfMetrics.cpp index 981ec934c40d631b1461b4f71c4f1e24e5b40a8e..311ff32df922f62480e417020edaab795bb7dbb7 100644 --- a/ets2panda/util/perfMetrics.cpp +++ b/ets2panda/util/perfMetrics.cpp @@ -272,7 +272,7 @@ static void DumpPerfMetricsImpl(std::optional prefix) } } - std::cout << ss.str(); + std::cout << ss.str() << std::flush; } void DumpPerfMetrics()