#pragma once
#ifndef _STATISTICALTIMER_CPU_H_
#define _STATISTICALTIMER_CPU_H_
#include <iosfwd>
#include <vector>
#include <algorithm>
#ifdef __FreeBSD__
#include <sys/timespec.h>
#endif
#include "statisticalTimer.h"
class CpuStatTimer : public baseStatTimer
{
typedef std::vector< cl_ulong > clkVector;
typedef std::pair< std::string, cl_uint > labelPair;
typedef std::vector< labelPair > stringVector;
stringVector labelID;
clkVector clkStart;
std::vector< clkVector > clkTicks;
cl_ulong clkFrequency;
#if !defined( _WIN32 )
timespec res;
#endif
clkVector::size_type nEvents, nSamples;
bool normalize;
CpuStatTimer( );
~CpuStatTimer( );
CpuStatTimer( const CpuStatTimer& );
CpuStatTimer& operator=( const CpuStatTimer& );
friend std::ostream& operator<<( std::ostream& os, const CpuStatTimer& s );
void AddSample( const size_t id, const cl_ulong n );
cl_double getMean( size_t id ) const;
cl_double getVariance( size_t id ) const;
cl_double getStdDev( size_t id ) const;
cl_double getAverageTime( size_t id ) const;
cl_double getMinimumTime( size_t id ) const;
public:
static CpuStatTimer& getInstance( );
void Start( size_t id );
void Stop( size_t id );
void Clear( );
void Reset( );
void Reserve( size_t nEvents, size_t nSamples );
size_t getUniqueID( const std::string& label, cl_uint groupID );
void setNormalize( bool norm );
void Print( );
size_t pruneOutliers( cl_double multiple );
std::vector< size_t > pruneOutliers( size_t id , cl_double multiple );
};
#endif