Files
WickedEngine/WickedEngine/wiTimer.h
T
Turánszki János 74cb74d3c9 version 0.60 (#367)
- namespace refactor (example: wiGraphics:: -> wi::graphics)
  - provided namespace compatibility macro for old user code: WICKEDENGINE_BACKWARDS_COMPATIBILITY_0_59
- resource manager will return `Resource` instead of `shared_ptr<Resource>` objects
- MAD shader optimizations
- implemented alpha to coverage with alpha tested materials when MSAA is enabled
- alpha testing fix with transparent shadow maps
- TLAS and scene buffers will be recreated less frequently when things get added/removed from the scene
2021-12-03 21:22:27 +01:00

39 lines
1004 B
C++

#pragma once
#include "CommonInclude.h"
#include <chrono>
namespace wi
{
struct Timer
{
std::chrono::high_resolution_clock::time_point timestamp = std::chrono::high_resolution_clock::now();
// Record a reference timestamp
inline void record()
{
timestamp = std::chrono::high_resolution_clock::now();
}
// Elapsed time in seconds since the wi::Timer creation or last call to record()
inline double elapsed_seconds()
{
auto timestamp2 = std::chrono::high_resolution_clock::now();
std::chrono::duration<double> time_span = std::chrono::duration_cast<std::chrono::duration<double>>(timestamp2 - timestamp);
return time_span.count();
}
// Elapsed time in milliseconds since the wi::Timer creation or last call to record()
inline double elapsed_milliseconds()
{
return elapsed_seconds() * 1000.0;
}
// Elapsed time in milliseconds since the wi::Timer creation or last call to record()
inline double elapsed()
{
return elapsed_milliseconds();
}
};
}