Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
cybozu::CpuClock Class Reference

#include <benchmark.hpp>

Public Member Functions

 CpuClock ()
 
void begin ()
 
void end ()
 
int getCount () const
 
uint64_t getClock () const
 
void clear ()
 
void put (const char *msg=0, int N=1) const
 

Static Public Attributes

static const int loopN1 = 1000000
 
static const int loopN2 = 1000
 
static const uint64_t maxClk = (uint64_t)500
 

Detailed Description

Definition at line 79 of file benchmark.hpp.

Constructor & Destructor Documentation

◆ CpuClock()

cybozu::CpuClock::CpuClock ( )
inline

Definition at line 84 of file benchmark.hpp.

84: clock_(0), count_(0) { t_.setTime(0, 0); }

Member Function Documentation

◆ begin()

void cybozu::CpuClock::begin ( )
inline

Definition at line 85 of file benchmark.hpp.

86 {
87 if (count_ == 0) t_.setCurrentTime(); // start
88 }

◆ clear()

void cybozu::CpuClock::clear ( )
inline

Definition at line 103 of file benchmark.hpp.

103{ t_.setTime(0, 0); clock_ = 0; count_ = 0; }

◆ end()

void cybozu::CpuClock::end ( )
inline

Definition at line 92 of file benchmark.hpp.

93 {
94 cybozu::Time cur(true);
95 int diffSec = (int)(cur.getTime() - t_.getTime());
96 int diffMsec = cur.getMsec() - t_.getMsec();
97 const int diff = diffSec * 1000 + diffMsec;
98 clock_ = diff;
99 count_++;
100 }
void diff(const std::string &a, const std::string &b)
Definition jmp.cpp:18
Here is the call graph for this function:

◆ getClock()

uint64_t cybozu::CpuClock::getClock ( ) const
inline

Definition at line 102 of file benchmark.hpp.

102{ return clock_; }
Here is the caller graph for this function:

◆ getCount()

int cybozu::CpuClock::getCount ( ) const
inline

Definition at line 101 of file benchmark.hpp.

101{ return count_; }
Here is the caller graph for this function:

◆ put()

void cybozu::CpuClock::put ( const char * msg = 0,
int N = 1 ) const
inline

Definition at line 104 of file benchmark.hpp.

105 {
106 double t = getClock() / double(getCount()) / N;
107 if (msg && *msg) printf("%s ", msg);
108 if (t > 1) {
109 printf("%6.2fmsec", t);
110 } else if (t > 1e-3) {
111 printf("%6.2fusec", t * 1e3);
112 } else {
113 printf("%6.2fnsec", t * 1e6);
114 }
115 if (msg && *msg) printf("\n");
116 }
int getCount() const
uint64_t getClock() const
LOGGING_API void printf(Category category, const char *format,...)
Definition Logging.cpp:30
const int N
Definition quantize.cpp:54
Here is the call graph for this function:

Member Data Documentation

◆ loopN1

const int cybozu::CpuClock::loopN1 = 1000000
static

Definition at line 118 of file benchmark.hpp.

◆ loopN2

const int cybozu::CpuClock::loopN2 = 1000
static

Definition at line 119 of file benchmark.hpp.

◆ maxClk

const uint64_t cybozu::CpuClock::maxClk = (uint64_t)500
static

Definition at line 120 of file benchmark.hpp.


The documentation for this class was generated from the following file: