Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
benchmark.hpp File Reference

measure exec time of function More...

#include <stdint.h>
#include <stdio.h>
#include <cybozu/time.hpp>
Include dependency graph for benchmark.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  cybozu::CpuClock
 

Namespaces

namespace  cybozu
 
namespace  cybozu::bench
 

Macros

#define CYBOZU_UNUSED
 
#define CYBOZU_BENCH(msg, func, ...)
 
#define CYBOZU_BENCH_C(msg, _N, func, ...)
 

Detailed Description

Author
MITSUNARI Shigeo

Definition in file benchmark.hpp.

Macro Definition Documentation

◆ CYBOZU_BENCH

#define CYBOZU_BENCH ( msg,
func,
... )
Value:
{ \
for (int i = 0; i < cybozu::CpuClock::loopN2; i++) { \
clk.begin(); \
for (int j = 0; j < cybozu::CpuClock::loopN1; j++) { func(__VA_ARGS__); } \
clk.end(); \
if (clk.getClock() > maxClk) break; \
} \
if (msg && *msg) clk.put(msg, cybozu::CpuClock::loopN1); \
cybozu::bench::g_clk = clk; cybozu::bench::g_loopNum = cybozu::CpuClock::loopN1; \
}
static const int loopN1
static const int loopN2
void put(const char *msg=0, int N=1) const
static const uint64_t maxClk
uint64_t getClock() const
unsigned __int64 uint64_t
Definition stdint.h:136
uint16_t j

Definition at line 140 of file benchmark.hpp.

140#define CYBOZU_BENCH(msg, func, ...) \
141{ \
142 const uint64_t maxClk = cybozu::CpuClock::maxClk; \
143 cybozu::CpuClock clk; \
144 for (int i = 0; i < cybozu::CpuClock::loopN2; i++) { \
145 clk.begin(); \
146 for (int j = 0; j < cybozu::CpuClock::loopN1; j++) { func(__VA_ARGS__); } \
147 clk.end(); \
148 if (clk.getClock() > maxClk) break; \
149 } \
150 if (msg && *msg) clk.put(msg, cybozu::CpuClock::loopN1); \
151 cybozu::bench::g_clk = clk; cybozu::bench::g_loopNum = cybozu::CpuClock::loopN1; \
152}

◆ CYBOZU_BENCH_C

#define CYBOZU_BENCH_C ( msg,
_N,
func,
... )
Value:
{ \
clk.begin(); \
for (int j = 0; j < _N; j++) { func(__VA_ARGS__); } \
clk.end(); \
if (msg && *msg) clk.put(msg, _N); \
cybozu::bench::g_clk = clk; cybozu::bench::g_loopNum = _N; \
}

Definition at line 159 of file benchmark.hpp.

159#define CYBOZU_BENCH_C(msg, _N, func, ...) \
160{ \
161 cybozu::CpuClock clk; \
162 clk.begin(); \
163 for (int j = 0; j < _N; j++) { func(__VA_ARGS__); } \
164 clk.end(); \
165 if (msg && *msg) clk.put(msg, _N); \
166 cybozu::bench::g_clk = clk; cybozu::bench::g_loopNum = _N; \
167}

◆ CYBOZU_UNUSED

#define CYBOZU_UNUSED

Definition at line 130 of file benchmark.hpp.