mirror of
https://github.com/HChaZZY/Stockfish.git
synced 2025-12-06 10:53:50 +08:00
Add dbg_clear helper function
closes https://github.com/official-stockfish/Stockfish/pull/5921 No functional change
This commit is contained in:
15
src/misc.cpp
15
src/misc.cpp
@@ -287,12 +287,18 @@ namespace {
|
||||
|
||||
template<size_t N>
|
||||
struct DebugInfo {
|
||||
std::atomic<int64_t> data[N] = {0};
|
||||
std::array<std::atomic<int64_t>, N> data = {0};
|
||||
|
||||
[[nodiscard]] constexpr std::atomic<int64_t>& operator[](size_t index) {
|
||||
assert(index < N);
|
||||
return data[index];
|
||||
}
|
||||
|
||||
constexpr DebugInfo& operator=(const DebugInfo& other) {
|
||||
for (size_t i = 0; i < N; i++)
|
||||
data[i].store(other.data[i].load());
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
struct DebugExtremes: public DebugInfo<3> {
|
||||
@@ -393,6 +399,13 @@ void dbg_print() {
|
||||
}
|
||||
}
|
||||
|
||||
void dbg_clear() {
|
||||
hit.fill({});
|
||||
mean.fill({});
|
||||
stdev.fill({});
|
||||
correl.fill({});
|
||||
extremes.fill({});
|
||||
}
|
||||
|
||||
// Used to serialize access to std::cout
|
||||
// to avoid multiple threads writing at the same time.
|
||||
|
||||
@@ -73,6 +73,7 @@ void dbg_stdev_of(int64_t value, int slot = 0);
|
||||
void dbg_extremes_of(int64_t value, int slot = 0);
|
||||
void dbg_correl_of(int64_t value1, int64_t value2, int slot = 0);
|
||||
void dbg_print();
|
||||
void dbg_clear();
|
||||
|
||||
using TimePoint = std::chrono::milliseconds::rep; // A value in milliseconds
|
||||
static_assert(sizeof(TimePoint) == sizeof(int64_t), "TimePoint should be 64 bits");
|
||||
|
||||
Reference in New Issue
Block a user