-// Copyright (C) 2010-2020 Joel Rosdahl and other contributors
+// Copyright (C) 2010-2021 Joel Rosdahl and other contributors
//
// See doc/AUTHORS.adoc for a complete list of contributors.
//
#include "Counters.hpp"
-#include "Statistic.hpp"
#include "assertions.hpp"
+#include <core/Statistic.hpp>
+
#include <algorithm>
-Counters::Counters() : m_counters(static_cast<size_t>(Statistic::END))
+Counters::Counters() : m_counters(static_cast<size_t>(core::Statistic::END))
{
}
uint64_t
-Counters::get(Statistic statistic) const
+Counters::get(core::Statistic statistic) const
{
const auto index = static_cast<size_t>(statistic);
- ASSERT(index < static_cast<size_t>(Statistic::END));
+ ASSERT(index < static_cast<size_t>(core::Statistic::END));
return index < m_counters.size() ? m_counters[index] : 0;
}
void
-Counters::set(Statistic statistic, uint64_t value)
+Counters::set(core::Statistic statistic, uint64_t value)
{
const auto index = static_cast<size_t>(statistic);
- ASSERT(index < static_cast<size_t>(Statistic::END));
+ ASSERT(index < static_cast<size_t>(core::Statistic::END));
m_counters[index] = value;
}
}
void
-Counters::increment(Statistic statistic, int64_t value)
+Counters::increment(core::Statistic statistic, int64_t value)
{
const auto i = static_cast<size_t>(statistic);
if (i >= m_counters.size()) {
#pragma once
-#include "Statistic.hpp"
+#include <core/Statistic.hpp>
#include <cstddef>
#include <cstdint>
public:
Counters();
- uint64_t get(Statistic statistic) const;
- void set(Statistic statistic, uint64_t value);
+ uint64_t get(core::Statistic statistic) const;
+ void set(core::Statistic statistic, uint64_t value);
uint64_t get_raw(size_t index) const;
void set_raw(size_t index, uint64_t value);
- void increment(Statistic statistic, int64_t value = 1);
+ void increment(core::Statistic statistic, int64_t value = 1);
void increment(const Counters& other);
size_t size() const;
#include "File.hpp"
#include "Logging.hpp"
#include "Stat.hpp"
-#include "Statistic.hpp"
#include "Util.hpp"
#include "fmtmacros.hpp"
+#include <core/Statistic.hpp>
#include <core/exceptions.hpp>
#include <core/wincompat.hpp>
#include <util/path.hpp>
const unsigned FLAG_NEVER = 4; // never show
const unsigned FLAG_NOSTATSLOG = 8; // don't show for statslog
+using core::Statistic;
using nonstd::nullopt;
using nonstd::optional;
#include <cassert>
+using core::Statistic;
using nonstd::nullopt;
using nonstd::optional;
using nonstd::string_view;
-// Copyright (C) 2020 Joel Rosdahl and other contributors
+// Copyright (C) 2020-2021 Joel Rosdahl and other contributors
//
// See doc/AUTHORS.adoc for a complete list of contributors.
//
#pragma once
#include "Args.hpp"
-#include "Statistic.hpp"
+
+#include <core/Statistic.hpp>
#include "third_party/nonstd/optional.hpp"
struct ProcessArgsResult
{
- ProcessArgsResult(Statistic error_);
+ ProcessArgsResult(core::Statistic error_);
ProcessArgsResult(const Args& preprocessor_args_,
const Args& extra_args_to_hash_,
const Args& compiler_args_);
// nullopt on success, otherwise the statistics counter that should be
// incremented.
- nonstd::optional<Statistic> error;
+ nonstd::optional<core::Statistic> error;
// Arguments (except -E) to send to the preprocessor.
Args preprocessor_args;
Args compiler_args;
};
-inline ProcessArgsResult::ProcessArgsResult(Statistic error_) : error(error_)
+inline ProcessArgsResult::ProcessArgsResult(core::Statistic error_)
+ : error(error_)
{
}
#endif
const char CCACHE_NAME[] = MYNAME;
+using core::Statistic;
using nonstd::nullopt;
using nonstd::optional;
using nonstd::string_view;
#pragma once
+namespace core {
+
// Statistics fields in storage order.
enum class Statistic {
none = 0,
END
};
+
+} // namespace core
#include <Counters.hpp>
#include <Logging.hpp>
#include <MiniTrace.hpp>
-#include <Statistic.hpp>
#include <Statistics.hpp>
#include <Util.hpp>
#include <assertions.hpp>
+#include <core/Statistic.hpp>
#include <core/exceptions.hpp>
#include <core/wincompat.hpp>
#include <fmtmacros.hpp>
# include <unistd.h>
#endif
+using core::Statistic;
+
namespace storage {
namespace primary {
// --- Statistics ---
- void increment_statistic(Statistic statistic, int64_t value = 1);
+ void increment_statistic(core::Statistic statistic, int64_t value = 1);
// Return a machine-readable string representing the final ccache result, or
// nullopt if there was no result.
#include <algorithm>
+using core::Statistic;
+
namespace storage {
namespace primary {
const auto new_stat = Stat::stat(cache_file.path(), Stat::OnError::log);
Statistics::update(stats_file, [=](auto& cs) {
- cs.increment(Statistic::cache_size_kibibyte,
+ cs.increment(core::Statistic::cache_size_kibibyte,
Util::size_change_kibibyte(old_stat, new_stat));
});
-// Copyright (C) 2020 Joel Rosdahl and other contributors
+// Copyright (C) 2020-2021 Joel Rosdahl and other contributors
//
// See doc/AUTHORS.adoc for a complete list of contributors.
//
// Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#include "../src/Counters.hpp"
-#include "../src/Statistic.hpp"
#include "TestUtil.hpp"
+#include <core/Statistic.hpp>
+
#include "third_party/doctest.h"
+using core::Statistic;
using TestUtil::TestContext;
TEST_SUITE_BEGIN("Counters");
// this program; if not, write to the Free Software Foundation, Inc., 51
// Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-#include "../src/Statistic.hpp"
#include "../src/Statistics.hpp"
#include "../src/Util.hpp"
#include "../src/fmtmacros.hpp"
#include "TestUtil.hpp"
+#include <core/Statistic.hpp>
+
#include "third_party/doctest.h"
+using core::Statistic;
using TestUtil::TestContext;
TEST_SUITE_BEGIN("Statistics");
#include "../src/Args.hpp"
#include "../src/Config.hpp"
#include "../src/Context.hpp"
-#include "../src/Statistic.hpp"
#include "../src/Util.hpp"
#include "../src/fmtmacros.hpp"
#include "TestUtil.hpp"
#include "argprocessing.hpp"
+#include <core/Statistic.hpp>
#include <core/wincompat.hpp>
#include "third_party/doctest.h"
#include <algorithm>
+using core::Statistic;
using TestUtil::TestContext;
namespace {