first commit
This commit is contained in:
51
include/framework/timing/benchmark.h
Normal file
51
include/framework/timing/benchmark.h
Normal file
@ -0,0 +1,51 @@
|
||||
/* -----------------------------------------------------------------------------
|
||||
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__
|
||||
Reference in New Issue
Block a user