MeshLib
 
Loading...
Searching...
No Matches
MRTimeRecord.h
Go to the documentation of this file.
1#pragma once
2
3#include "MRMeshFwd.h"
4#include "MRLog.h"
5#include <chrono>
6#include <map>
7#include <string>
8
9namespace MR
10{
11
14
16{
17 int count = 0;
18 std::chrono::nanoseconds time = {};
19 double seconds() const { return time.count() * 1e-9; }
20};
21
23{
24 TimeRecord* parent = nullptr;
25 std::map<std::string, TimeRecord> children;
26
27 // returns summed time of immediate children
28 MRMESH_API std::chrono::nanoseconds childTime() const;
29 std::chrono::nanoseconds myTime() const { return time - childTime(); }
30
31 double mySeconds() const { return myTime().count() * 1e-9; }
32};
33
35{
36 const char * threadName = nullptr;
37 std::chrono::time_point<std::chrono::high_resolution_clock> started = std::chrono::high_resolution_clock::now();
38 bool printTreeInDtor = true;
39 double minTimeSec = 0.1;
40 // prolong logger life
41 std::shared_ptr<spdlog::logger> loggerHandle = Logger::instance().getSpdLogger();
42 MRMESH_API ThreadRootTimeRecord( const char * tdName );
45};
46
49
52
54
55} // namespace MR
#define MRMESH_API
Definition MRMesh/MRMeshFwd.h:46
static MRMESH_API Logger & instance()
MRMESH_API const std::shared_ptr< spdlog::logger > & getSpdLogger() const
store this pointer if need to prolong logger life time (necessary to log something from destructors)
MRMESH_API void registerThreadRootTimeRecord(ThreadRootTimeRecord &root)
installs given record in the current thread (no record must be installed before)
MRMESH_API void unregisterThreadRootTimeRecord(ThreadRootTimeRecord &root)
un-installs given record in the current thread
Definition MRCameraOrientationPlugin.h:7
Definition MRTimeRecord.h:16
int count
Definition MRTimeRecord.h:17
double seconds() const
Definition MRTimeRecord.h:19
std::chrono::nanoseconds time
Definition MRTimeRecord.h:18
Definition MRTimeRecord.h:35
MRMESH_API ~ThreadRootTimeRecord()
MRMESH_API ThreadRootTimeRecord(const char *tdName)
bool printTreeInDtor
Definition MRTimeRecord.h:38
std::chrono::time_point< std::chrono::high_resolution_clock > started
Definition MRTimeRecord.h:37
MRMESH_API void printTree()
const char * threadName
Definition MRTimeRecord.h:36
std::shared_ptr< spdlog::logger > loggerHandle
Definition MRTimeRecord.h:41
double minTimeSec
Definition MRTimeRecord.h:39
Definition MRTimeRecord.h:23
MRMESH_API std::chrono::nanoseconds childTime() const
double mySeconds() const
Definition MRTimeRecord.h:31
TimeRecord * parent
Definition MRTimeRecord.h:24
std::chrono::nanoseconds myTime() const
Definition MRTimeRecord.h:29
std::map< std::string, TimeRecord > children
Definition MRTimeRecord.h:25