21 lines
936 B
C++
21 lines
936 B
C++
// Diagnostic only. Plain fixed C++ state shared by this DSO's instances.
|
|
// Single main-thread, one isolated headless tick only; not concurrent-safe.
|
|
// No Godot object, name, container, allocation or callback in counters.
|
|
#include <array>
|
|
#include <chrono>
|
|
#include <algorithm>
|
|
namespace tree_diag321 {
|
|
struct Row { int64_t calls=0, inclusive_us=0, max_us=0; };
|
|
static std::array<Row,9> rows{};
|
|
static int64_t active=0;
|
|
struct Timer {
|
|
size_t index; std::chrono::steady_clock::time_point started;
|
|
explicit Timer(size_t i) noexcept : index(i),started(std::chrono::steady_clock::now()) { ++active; }
|
|
~Timer() noexcept {
|
|
const auto us=std::max<int64_t>(0,std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::steady_clock::now()-started).count());
|
|
auto &r=rows[index]; ++r.calls; r.inclusive_us+=us; r.max_us=std::max(r.max_us,us); --active;
|
|
}
|
|
Timer(const Timer&)=delete; Timer& operator=(const Timer&)=delete;
|
|
};
|
|
}
|