40 lines
903 B
C++
40 lines
903 B
C++
/* -----------------------------------------------------------------------------
|
|
GSFramework
|
|
Copyright 2001-2013 Emmanuel Julien. All Rights Reserved.
|
|
----------------------------------------------------------------------------- */
|
|
|
|
|
|
#include "timing/benchmark.h"
|
|
#include "sort/sort.h"
|
|
#include "platform.h"
|
|
|
|
using namespace GS;
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
void Benchmark::Start()
|
|
{
|
|
r_clock = Platform::Get().GetTime();
|
|
}
|
|
void Benchmark::Stop()
|
|
{
|
|
Time c_clock = Platform::Get().GetTime();
|
|
|
|
t_clock += c_clock - r_clock;
|
|
r_clock = c_clock;
|
|
}
|
|
float Benchmark::GetMs() const
|
|
{ return avg.GetMedian(); }
|
|
void Benchmark::Reset()
|
|
{
|
|
avg.LogValue(t_clock.toMs());
|
|
t_clock.setSec(0);
|
|
}
|
|
|
|
Benchmark::Benchmark(bool start)
|
|
{
|
|
if (start)
|
|
Start();
|
|
}
|
|
//------------------------------------------------------------------------------
|