diff options
author | Klaus Aehlig <klaus.aehlig@huawei.com> | 2022-02-22 17:03:21 +0100 |
---|---|---|
committer | Klaus Aehlig <klaus.aehlig@huawei.com> | 2022-02-22 17:03:21 +0100 |
commit | 619def44c1cca9f3cdf63544d5f24f2c7a7d9b77 (patch) | |
tree | 01868de723cb82c86842f33743fa7b14e24c1fa3 /src/buildtool/common/statistics.hpp | |
download | justbuild-619def44c1cca9f3cdf63544d5f24f2c7a7d9b77.tar.gz |
Initial self-hosting commit
This is the initial version of our tool that is able to
build itself. In can be bootstrapped by
./bin/bootstrap.py
Co-authored-by: Oliver Reiche <oliver.reiche@huawei.com>
Co-authored-by: Victor Moreno <victor.moreno1@huawei.com>
Diffstat (limited to 'src/buildtool/common/statistics.hpp')
-rw-r--r-- | src/buildtool/common/statistics.hpp | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/src/buildtool/common/statistics.hpp b/src/buildtool/common/statistics.hpp new file mode 100644 index 00000000..a7b89791 --- /dev/null +++ b/src/buildtool/common/statistics.hpp @@ -0,0 +1,61 @@ +#ifndef INCLUDED_SRC_BUILDTOOL_COMMON_STATISTICS_HPP +#define INCLUDED_SRC_BUILDTOOL_COMMON_STATISTICS_HPP + +#include <atomic> + +class Statistics { + public: + [[nodiscard]] static auto Instance() noexcept -> Statistics& { + static Statistics instance{}; + return instance; + } + + void Reset() noexcept { + num_actions_queued_ = 0; + num_actions_cached_ = 0; + num_actions_flaky_ = 0; + num_actions_flaky_tainted_ = 0; + num_rebuilt_actions_compared_ = 0; + num_rebuilt_actions_missing_ = 0; + } + void IncrementActionsQueuedCounter() noexcept { ++num_actions_queued_; } + void IncrementActionsCachedCounter() noexcept { ++num_actions_cached_; } + void IncrementActionsFlakyCounter() noexcept { ++num_actions_flaky_; } + void IncrementActionsFlakyTaintedCounter() noexcept { + ++num_actions_flaky_tainted_; + } + void IncrementRebuiltActionMissingCounter() noexcept { + ++num_rebuilt_actions_missing_; + } + void IncrementRebuiltActionComparedCounter() noexcept { + ++num_rebuilt_actions_compared_; + } + [[nodiscard]] auto ActionsQueuedCounter() const noexcept -> int { + return num_actions_queued_; + } + [[nodiscard]] auto ActionsCachedCounter() const noexcept -> int { + return num_actions_cached_; + } + [[nodiscard]] auto ActionsFlakyCounter() const noexcept -> int { + return num_actions_flaky_; + } + [[nodiscard]] auto ActionsFlakyTaintedCounter() const noexcept -> int { + return num_actions_flaky_tainted_; + } + [[nodiscard]] auto RebuiltActionMissingCounter() const noexcept -> int { + return num_rebuilt_actions_missing_; + } + [[nodiscard]] auto RebuiltActionComparedCounter() const noexcept -> int { + return num_rebuilt_actions_compared_; + } + + private: + std::atomic<int> num_actions_queued_{}; + std::atomic<int> num_actions_cached_{}; + std::atomic<int> num_actions_flaky_{}; + std::atomic<int> num_actions_flaky_tainted_{}; + std::atomic<int> num_rebuilt_actions_missing_{}; + std::atomic<int> num_rebuilt_actions_compared_{}; +}; + +#endif // INCLUDED_SRC_BUILDTOOL_COMMON_STATISTICS_HPP |