54 lines
1.3 KiB
C++
54 lines
1.3 KiB
C++
/* -----------------------------------------------------------------------------
|
|
GSFramework
|
|
Copyright 2001-2013 Emmanuel Julien. All Rights Reserved.
|
|
----------------------------------------------------------------------------- */
|
|
|
|
|
|
#include "timing/loop_benchmark.h"
|
|
#include "platform.h"
|
|
#include "log/log.h"
|
|
|
|
using namespace GS;
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
void LoopBenchmark::MarkLoop()
|
|
{
|
|
++loop_count;
|
|
|
|
Time c_time = Platform::Get().GetTime();
|
|
|
|
t_time += c_time - r_time;
|
|
r_time = c_time;
|
|
|
|
float t_ms = t_time.toMs();
|
|
|
|
if (t_ms > 1000.f)
|
|
{
|
|
ms = t_ms / loop_count;
|
|
|
|
loop_count = 0;
|
|
t_time.setSec(0);
|
|
}
|
|
}
|
|
//------------------------------------------------------------------------------
|
|
|
|
//------------------------------------------------------------------------------
|
|
float LoopBenchmark::GetMs() const
|
|
{ return ms; }
|
|
float LoopBenchmark::GetFps() const
|
|
{ return ms ? 1000.f / ms : 0.f; }
|
|
//------------------------------------------------------------------------------
|
|
|
|
//------------------------------------------------------------------------------
|
|
void LoopBenchmark::Reset()
|
|
{
|
|
ms = 0.f;
|
|
|
|
loop_count = 0;
|
|
|
|
r_time = Platform::Get().GetTime();
|
|
t_time.setSec(0);
|
|
}
|
|
//------------------------------------------------------------------------------
|