52 lines
858 B
C++
52 lines
858 B
C++
/* -----------------------------------------------------------------------------
|
|
GSFramework
|
|
Copyright 2001-2013 Emmanuel Julien. All Rights Reserved.
|
|
----------------------------------------------------------------------------- */
|
|
|
|
|
|
#ifndef __NBENCHMARK__
|
|
#define __NBENCHMARK__
|
|
|
|
|
|
#include "time/ntime.h"
|
|
#include "container/smart_median_average.h"
|
|
|
|
|
|
namespace GS {
|
|
|
|
/*!
|
|
@short Benchmark.
|
|
@author Emmanuel Julien (ejulien@owloh.com)
|
|
*/
|
|
class Benchmark
|
|
{
|
|
SmartMedianAverage <float> avg;
|
|
Time r_clock, t_clock;
|
|
|
|
public:
|
|
|
|
void Start();
|
|
void Stop();
|
|
|
|
float GetMs() const;
|
|
void Reset();
|
|
|
|
Benchmark(bool start = false);
|
|
};
|
|
|
|
/// Scoped benchmark.
|
|
struct ScopedBenchmark
|
|
{
|
|
Benchmark &bench;
|
|
|
|
ScopedBenchmark(Benchmark &b) : bench(b)
|
|
{ bench.Start(); }
|
|
~ScopedBenchmark()
|
|
{ bench.Stop(); }
|
|
};
|
|
|
|
} // GS
|
|
|
|
|
|
#endif // __NBENCHMARK__
|