MeshLib Documentation
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 "MRPch/MRBindingMacros.h"
6#include <chrono>
7#include <map>
8#include <string>
9
10namespace MR
11{
12
15
16struct MR_BIND_IGNORE SimpleTimeRecord
17{
18 int count = 0;
19 std::chrono::nanoseconds time = {};
20 double seconds() const { return time.count() * 1e-9; }
21};
22
23struct MR_BIND_IGNORE TimeRecord : SimpleTimeRecord
24{
25 TimeRecord* parent = nullptr;
26 std::map<std::string, TimeRecord> children;
27
28 // returns summed time of immediate children
29 MRMESH_API std::chrono::nanoseconds childTime() const;
30 std::chrono::nanoseconds myTime() const { return time - childTime(); }
31
32 double mySeconds() const { return myTime().count() * 1e-9; }
33};
34
35struct MR_BIND_IGNORE ThreadRootTimeRecord : TimeRecord
36{
37 const char * threadName = nullptr;
38 std::chrono::time_point<std::chrono::high_resolution_clock> started = std::chrono::high_resolution_clock::now();
39 bool printTreeInDtor = true;
40 double minTimeSec = 0.1;
41 // prolong logger life
42 std::shared_ptr<spdlog::logger> loggerHandle = Logger::instance().getSpdLogger();
43 MRMESH_API ThreadRootTimeRecord( const char * tdName );
46};
47
50
53
55
56} // namespace MR
#define MRMESH_API
Definition MRMesh/MRMeshFwd.h:46
MR_BIND_IGNORE MRMESH_API void registerThreadRootTimeRecord(ThreadRootTimeRecord &root)
installs given record in the current thread (no record must be installed before)
MR_BIND_IGNORE MRMESH_API void unregisterThreadRootTimeRecord(ThreadRootTimeRecord &root)
un-installs given record in the current thread
Definition MRCameraOrientationPlugin.h:8
Definition MRTimeRecord.h:17
double seconds() const
Definition MRTimeRecord.h:20
Definition MRTimeRecord.h:36
MRMESH_API ~ThreadRootTimeRecord()
MRMESH_API ThreadRootTimeRecord(const char *tdName)
MRMESH_API void printTree()
Definition MRTimeRecord.h:24
MRMESH_API std::chrono::nanoseconds childTime() const
double mySeconds() const
Definition MRTimeRecord.h:32
std::chrono::nanoseconds myTime() const
Definition MRTimeRecord.h:30
std::map< std::string, TimeRecord > children
Definition MRTimeRecord.h:26