diff options
-rw-r--r-- | src/buildtool/profile/profile.cpp | 6 | ||||
-rw-r--r-- | src/buildtool/profile/profile.hpp | 3 |
2 files changed, 7 insertions, 2 deletions
diff --git a/src/buildtool/profile/profile.cpp b/src/buildtool/profile/profile.cpp index 3ee7f2a6..9a7eaf7d 100644 --- a/src/buildtool/profile/profile.cpp +++ b/src/buildtool/profile/profile.cpp @@ -26,6 +26,9 @@ void Profile::Write(int exit_code) { for (auto const& [k, v] : actions_) { auto entry = nlohmann::json::object(); entry["cached"] = v.cached; + if (not v.cached) { + entry["duration"] = v.duration; + } actions[k] = entry; } profile_["actions"] = actions; @@ -48,5 +51,6 @@ void Profile::SetConfiguration(nlohmann::json configuration) { void Profile::NoteActionCompleted(std::string const& id, IExecutionResponse::Ptr const& response) { std::unique_lock lock{mutex_}; - actions_[id] = ActionData{.cached = response->IsCached()}; + actions_[id] = ActionData{.cached = response->IsCached(), + .duration = response->ExecutionDuration()}; } diff --git a/src/buildtool/profile/profile.hpp b/src/buildtool/profile/profile.hpp index 6cf222e1..60f8f007 100644 --- a/src/buildtool/profile/profile.hpp +++ b/src/buildtool/profile/profile.hpp @@ -28,7 +28,7 @@ class Profile { public: explicit Profile(std::optional<std::string> output_file) - : output_file_{std::move(output_file)}, actions_{}, mutex_{} { + : output_file_{std::move(output_file)} { profile_ = nlohmann::json::object(); } @@ -41,6 +41,7 @@ class Profile { private: struct ActionData { bool cached; + double duration; }; std::optional<std::string> output_file_; |