63 lines
1.4 KiB
C++
63 lines
1.4 KiB
C++
#pragma once
|
|
#include "utilities.hh"
|
|
|
|
|
|
struct T_ProfilerSamples
|
|
{
|
|
float sum;
|
|
uint32_t nSamples;
|
|
};
|
|
|
|
|
|
struct T_Profiler
|
|
{
|
|
static constexpr uint32_t Samples = 4;
|
|
static constexpr uint32_t History = 4;
|
|
static constexpr uint32_t Invalid = 0xffffffff;
|
|
|
|
void clear( );
|
|
|
|
void startFrame( );
|
|
void start( __rd__ std::string const& section );
|
|
void end( __rd__ std::string const& section );
|
|
void endFrame( );
|
|
|
|
uint32_t sections( ) const noexcept
|
|
{ return sections_.size( ); }
|
|
|
|
std::string const& nameOf(
|
|
__rd__ const uint32_t section ) const
|
|
{ return sections_[ section ]; }
|
|
|
|
float durationOf( __rd__ const uint32_t section ) const
|
|
{ return secDurations_[ section ]; }
|
|
float startOf( __rd__ const uint32_t section ) const
|
|
{ return secStarts_[ section ]; }
|
|
|
|
void makeUI( );
|
|
bool& uiEnabled( ) { return uiEnabled_; }
|
|
|
|
private:
|
|
using T_SamplesList_ = std::vector< T_ProfilerSamples >;
|
|
using T_Data_ = std::vector< T_SamplesList_ >;
|
|
|
|
uint32_t find( __rd__ std::string const& section ) const;
|
|
float computeDuration(
|
|
__rd__ const uint32_t section ) const;
|
|
|
|
uint32_t previous_;
|
|
uint32_t current_;
|
|
|
|
std::vector< std::string > sections_;
|
|
std::vector< uint32_t > chain_;
|
|
std::vector< uint32_t > parents_;
|
|
T_Data_ samples_;
|
|
std::vector< uint64_t > starts_;
|
|
|
|
std::vector< float > secDurations_;
|
|
std::vector< float > secStarts_;
|
|
|
|
bool uiEnabled_ = false;
|
|
std::vector< int > displayed_;
|
|
};
|
|
|