1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-29 23:33:05 +04:00

core(logger): dump timestamp information with message

This commit is contained in:
Alexander Alekhin
2021-11-20 15:34:23 +00:00
parent 93b6e80cd7
commit 61f1ee2d2d
4 changed files with 74 additions and 18 deletions
+45
View File
@@ -934,6 +934,51 @@ int64 getCPUTickCount(void)
#endif
namespace internal {
class Timestamp
{
public:
const int64 zeroTickCount;
const double ns_in_ticks;
Timestamp()
: zeroTickCount(getTickCount())
, ns_in_ticks(1e9 / getTickFrequency())
{
// nothing
}
int64 getTimestamp()
{
int64 t = getTickCount();
return (int64)((t - zeroTickCount) * ns_in_ticks);
}
static Timestamp& getInstance()
{
static Timestamp g_timestamp;
return g_timestamp;
}
};
class InitTimestamp {
public:
InitTimestamp() {
Timestamp::getInstance();
}
};
static InitTimestamp g_initialize_timestamp; // force zero timestamp initialization
} // namespace
int64 getTimestampNS()
{
return internal::Timestamp::getInstance().getTimestamp();
}
const String& getBuildInformation()
{
static String build_info =