MeshLib Documentation
Loading...
Searching...
No Matches
MRTimer.h
Go to the documentation of this file.
1#pragma once
2
3#include "MRMeshFwd.h"
4#include "MRPch/MRBindingMacros.h"
5#include <chrono>
6#include <string>
7
8namespace MR
9{
10
13
14struct TimeRecord;
15
16class MR_BIND_IGNORE Timer
17{
18public:
19 Timer( std::string name ) { start( std::move( name ) ); }
20 ~Timer() { finish(); }
21
22 MRMESH_API void restart( std::string name );
23 MRMESH_API void start( std::string name );
25
26 Timer( const Timer & ) = delete;
27 Timer & operator =( const Timer & ) = delete;
28 Timer( Timer && ) = delete;
29 Timer & operator =( Timer && ) = delete;
30
31 std::chrono::duration<double> secondsPassed() const { return std::chrono::high_resolution_clock::now() - start_; }
32
33private:
34 std::chrono::time_point<std::chrono::high_resolution_clock> start_;
35 bool started_{ false };
36};
37
40MRMESH_API void printTimingTreeAtEnd( bool on, double minTimeSec = 0.1 );
41
44
47MRMESH_API void printTimingTreeAndStop( double minTimeSec = 0.1 );
48
50
51} // namespace MR
52
53#define MR_TIMER MR::Timer _timer( __FUNCTION__ );
54#define MR_NAMED_TIMER(name) MR::Timer _named_timer( name );
#define MRMESH_API
Definition MRMesh/MRMeshFwd.h:46
Definition MRTimer.h:17
MRMESH_API void finish()
MRMESH_API void restart(std::string name)
Timer(const Timer &)=delete
~Timer()
Definition MRTimer.h:20
std::chrono::duration< double > secondsPassed() const
Definition MRTimer.h:31
MRMESH_API void start(std::string name)
Timer(Timer &&)=delete
Timer(std::string name)
Definition MRTimer.h:19
MRMESH_API void printTimingTreeAtEnd(bool on, double minTimeSec=0.1)
MRMESH_API void printCurrentTimerBranch()
prints current timer branch
MRMESH_API void printTimingTreeAndStop(double minTimeSec=0.1)
Definition MRCameraOrientationPlugin.h:8