QuasarEngine
Cross-platform 3D engine and editor
Loading...
Searching...
No Matches
Quasar::ScopedTimer Class Reference

Measures the time between its creation and the end of its scope, then logs it as an engine info message. More...

#include <quasar/core/ScopedTimer.h>

Public Member Functions

 ScopedTimer (std::string name)
 Starts measuring right away.
 ~ScopedTimer ()
 Logs the name and the time elapsed since the creation, in milliseconds.
 ScopedTimer (const ScopedTimer &)=delete
ScopedTimer & operator= (const ScopedTimer &)=delete
 ScopedTimer (ScopedTimer &&)=delete
ScopedTimer & operator= (ScopedTimer &&)=delete

Detailed Description

Measures the time between its creation and the end of its scope, then logs it as an engine info message.

The timer starts in the constructor and the time is logged in the destructor, so the scope does the work. The message has the form <name> took <time> ms:

{ ScopedTimer timer("LoadScene"); LoadScene(); }

To measure a scope in Debug only, use QUASAR_SCOPED_TIMER() instead of creating a ScopedTimer directly.

Log::Init() must have been called before the scope ends.

Constructor & Destructor Documentation

◆ ScopedTimer()

Quasar::ScopedTimer::ScopedTimer ( std::string name)
explicit

Starts measuring right away.

Parameters
nameName written in the log message, to know which scope was measured.

The documentation for this class was generated from the following file: