From 4d70a94545629affd3d68dda74ec71c62a3bb0c4 Mon Sep 17 00:00:00 2001 From: Kyle Edwards Date: Thu, 10 Nov 2022 14:44:58 -0500 Subject: Profiling: Profile genex evaluation --- Source/cmGeneratorExpression.cxx | 13 ++++++++++++- Source/cmGeneratorExpressionEvaluator.cxx | 31 ++++++++++++++++++++++++++++++- 2 files changed, 42 insertions(+), 2 deletions(-) diff --git a/Source/cmGeneratorExpression.cxx b/Source/cmGeneratorExpression.cxx index 8f0db47..21ace89 100644 --- a/Source/cmGeneratorExpression.cxx +++ b/Source/cmGeneratorExpression.cxx @@ -16,6 +16,7 @@ #include "cmLocalGenerator.h" #include "cmStringAlgorithms.h" #include "cmSystemTools.h" +#include "cmake.h" cmGeneratorExpression::cmGeneratorExpression(cmake& cmakeInstance, cmListFileBacktrace backtrace) @@ -43,6 +44,11 @@ std::string cmGeneratorExpression::Evaluate( cmGeneratorTarget const* currentTarget, std::string const& language) { if (Find(input) != std::string::npos) { +#ifndef CMAKE_BOOTSTRAP + auto profilingRAII = lg->GetCMakeInstance()->CreateProfilingEntry( + "genex_compile_eval", input); +#endif + cmCompiledGeneratorExpression cge(*lg->GetCMakeInstance(), cmListFileBacktrace(), std::move(input)); return cge.Evaluate(lg, config, headTarget, dagChecker, currentTarget, @@ -102,10 +108,15 @@ const std::string& cmCompiledGeneratorExpression::EvaluateWithContext( } cmCompiledGeneratorExpression::cmCompiledGeneratorExpression( - cmake& /*cmakeInstance*/, cmListFileBacktrace backtrace, std::string input) + cmake& cmakeInstance, cmListFileBacktrace backtrace, std::string input) : Backtrace(std::move(backtrace)) , Input(std::move(input)) { +#ifndef CMAKE_BOOTSTRAP + auto profilingRAII = + cmakeInstance.CreateProfilingEntry("genex_compile", this->Input); +#endif + cmGeneratorExpressionLexer l; std::vector tokens = l.Tokenize(this->Input); this->NeedsEvaluation = l.GetSawGeneratorExpression(); diff --git a/Source/cmGeneratorExpressionEvaluator.cxx b/Source/cmGeneratorExpressionEvaluator.cxx index fec309c..b239408 100644 --- a/Source/cmGeneratorExpressionEvaluator.cxx +++ b/Source/cmGeneratorExpressionEvaluator.cxx @@ -4,8 +4,14 @@ #include +#ifndef CMAKE_BOOTSTRAP +# include +#endif + #include "cmGeneratorExpressionContext.h" #include "cmGeneratorExpressionNode.h" +#include "cmLocalGenerator.h" +#include "cmake.h" GeneratorExpressionContent::GeneratorExpressionContent( const char* startContent, size_t length) @@ -61,6 +67,12 @@ std::string GeneratorExpressionContent::Evaluate( cmGeneratorExpressionContext* context, cmGeneratorExpressionDAGChecker* dagChecker) const { +#ifndef CMAKE_BOOTSTRAP + auto evalProfilingRAII = + context->LG->GetCMakeInstance()->CreateProfilingEntry( + "genex_eval", this->GetOriginalExpression()); +#endif + std::string identifier; { for (const auto& pExprEval : this->IdentifierChildren) { @@ -101,7 +113,24 @@ std::string GeneratorExpressionContent::Evaluate( return std::string(); } - return node->Evaluate(parameters, context, this, dagChecker); + { +#ifndef CMAKE_BOOTSTRAP + auto execProfilingRAII = + context->LG->GetCMakeInstance()->CreateProfilingEntry( + "genex_exec", identifier, [¶meters]() -> Json::Value { + Json::Value args = Json::objectValue; + if (!parameters.empty()) { + args["genexArgs"] = Json::arrayValue; + for (auto const& parameter : parameters) { + args["genexArgs"].append(parameter); + } + } + return args; + }); +#endif + + return node->Evaluate(parameters, context, this, dagChecker); + } } std::string GeneratorExpressionContent::EvaluateParameters( -- cgit v0.12