/
BirdLeon
/
ROBLOX2016
Обзор
Документация
Войти
/
BirdLeon
/
ROBLOX2016
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
App/include/solver/SolverProfiler.h
59 строк
1 KB
PatoFlamejanteTV
full source code
19 дек 2024, 19:11
19 дек 2024, 19:11
05db15d
Код
Авторство
О чём код?
#pragma once #include "rbx/rbxTime.h" #include "RbxAssert.h" #include "util/standardout.h" namespace RBX { // // Prints average timing after the given number of samples were taken // class SolverProfiler { public: SolverProfiler( int _samples, const char* _format ): maxSamples( _samples ), format( _format ) { accumulator = Time::Interval::zero(); currentSamples = 0; } void start() { #ifdef ENABLE_SOLVER_PROFILER startTime = Time::now( Time::Precise ); #endif } void end() { #ifdef ENABLE_SOLVER_PROFILER Time::Interval total = Time::now( Time::Precise ) - startTime; accumulator += total; currentSamples++; #endif } void printStats() { #ifdef ENABLE_SOLVER_PROFILER static bool enable = true; if( currentSamples >= maxSamples && enable ) { currentSamples = 0; StandardOut::singleton()->printf( MESSAGE_OUTPUT, format, accumulator.msec() / maxSamples ); accumulator = Time::Interval::zero(); } #endif } private: RBX::Time startTime; Time::Interval accumulator; const char* format; int maxSamples; int currentSamples; }; }