QuasarEngine
Cross-platform 3D engine and editor
Loading...
Searching...
No Matches
ScopedTimer.h File Reference

Timer that logs how long a scope took when the scope ends. More...

#include <quasar/core/Base.h>
#include <quasar/core/Timer.h>
#include <string>

Go to the source code of this file.

Classes

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

Namespaces

namespace  Quasar
 Contains all the engine code.

Macros

#define QUASAR_SCOPED_TIMER(name)
 Measures the rest of the current scope and logs the time with the given name.

Detailed Description

Timer that logs how long a scope took when the scope ends.

Author
Fadiwahbeh
Date
2026-10-23

Macro Definition Documentation

◆ QUASAR_SCOPED_TIMER

#define QUASAR_SCOPED_TIMER ( name)
Value:
do \
{ \
if constexpr (false) \
{ \
static_cast<void>(::Quasar::ScopedTimer(name)); \
} \
} while (false)
Measures the time between its creation and the end of its scope, then logs it as an engine info messa...
Definition ScopedTimer.h:27

Measures the rest of the current scope and logs the time with the given name.

Removed from Release builds, where name is still checked by the compiler but never evaluated.

{ QUASAR_SCOPED_TIMER("LoadScene"); LoadScene(); }

The macro creates a ScopedTimer with a variable name that contains the line number, so several timers can be used in the same scope, one per line. Because name is still compiled in Release, a variable used only as the name does not cause an unused variable warning.