PhoenixMicroBenchmark
1.3.0
Toolset for function micro-benchmarking
Toggle main menu visibility
Loading...
Searching...
No Matches
micro_benchmark_rdtsc_impl.h
Go to the documentation of this file.
1
/***************************************
2
Auteur : Pierre Aubert
3
Mail : pierre.aubert@lapp.in2p3.fr
4
Licence : CeCILL-C
5
****************************************/
6
7
#ifndef __MICRO_BENCHMARK_RDTSC_IMPL_H__
8
#define __MICRO_BENCHMARK_RDTSC_IMPL_H__
9
10
#include "
phoenix_timer.h
"
11
#include "
micro_benchmark_rdtsc.h
"
12
14
21
template
<
typename
_Callable,
typename
... _Args>
22
void
micro_benchmarkRdtsc
(
double
& ellapsedTimeCy,
double
& ellapsedTimeErrorCy,
size_t
nbTestPerf,
size_t
nbCallPerTest,
23
_Callable&& __f, _Args&&... __args)
24
{
25
VecEllapsedTime
vecTimeCy;
26
for
(
size_t
i(0lu); i < nbTestPerf; ++i){
27
//Stating the timer
28
size_t
beginTime =
phoenix_rdtsc
();
29
for
(
size_t
j(0lu); j < nbCallPerTest; ++j){
30
__f(__args...);
31
}
32
//Get the time of the nbCallPerTest calls
33
size_t
elapsedTime(
phoenix_rdtsc
() - beginTime);
34
double
fullCy(elapsedTime/((
double
)nbCallPerTest));
35
vecTimeCy.push_back(fullCy);
36
}
37
MapOrderedTime
mapOrderTime;
38
micro_benchmarkVecToMap
(mapOrderTime, vecTimeCy);
39
size_t
nbValueUsed(vecTimeCy.size()*0.7 + 1lu);
40
if
(nbValueUsed > vecTimeCy.size()){
41
nbValueUsed = vecTimeCy.size();
42
}
43
micro_benchmarkComputeTime
(ellapsedTimeCy, ellapsedTimeErrorCy, mapOrderTime, nbValueUsed);
44
}
45
47
57
template
<
typename
_Callable,
typename
... _Args>
58
void
micro_benchmarkRdtsc
(
double
& ellapsedTimeCy,
double
& ellapsedTimeErrorCy,
59
double
& timePerElement,
double
& timeErrorPerElement,
size_t
nbTestPerf,
size_t
nbCallPerTest,
size_t
nbElement,
60
_Callable&& __f, _Args&&... __args)
61
{
62
micro_benchmarkRdtsc
(ellapsedTimeCy, ellapsedTimeErrorCy, nbTestPerf, nbCallPerTest, __f, __args...);
63
timePerElement = ellapsedTimeCy/((double)nbElement);
64
timeErrorPerElement = ellapsedTimeErrorCy/((double)nbElement);
65
}
66
68
75
template
<
typename
_Callable,
typename
... _Args>
76
void
micro_benchmarkRdtscPrint
(
const
std::string & testName,
size_t
nbTestPerf,
size_t
nbCallPerTest,
size_t
nbElement, _Callable&& __f, _Args&&... __args){
77
double
ellapsedTimeCy(0.0), ellapsedTimeErrorCy(0.0), timePerElement(0.0), timeErrorPerElement(0.0);
78
micro_benchmarkRdtsc
(ellapsedTimeCy, ellapsedTimeErrorCy, timePerElement, timeErrorPerElement, nbTestPerf, nbCallPerTest, nbElement, __f, __args...);
79
80
std::cout << testName <<
" : nbElement = "
<<nbElement<<
", timePerElement = "
<< timePerElement <<
" cy/el ± "
<<timeErrorPerElement<<
", elapsedTime = "
<< ellapsedTimeCy <<
" cy ± "
<<ellapsedTimeErrorCy << std::endl;
81
std::cerr << nbElement <<
"\t"
<< timePerElement <<
"\t"
<< ellapsedTimeCy <<
"\t"
<< timeErrorPerElement <<
"\t"
<< ellapsedTimeErrorCy << std::endl;
82
}
83
84
85
#endif
micro_benchmarkVecToMap
void micro_benchmarkVecToMap(MapOrderedTime &mapOrderTime, const VecEllapsedTime &vecTime)
Fill the map of ordered time with the vector.
Definition
micro_benchmark_common.cpp:15
micro_benchmarkComputeTime
void micro_benchmarkComputeTime(double &ellapsedTimeNs, double &ellapsedTimeErrorNs, const MapOrderedTime &mapOrderTime, size_t nbValueToBeUsed)
Compute the total computing time and associated error with the given data.
Definition
micro_benchmark_common.cpp:32
MapOrderedTime
std::map< double, size_t > MapOrderedTime
Map of the ordered ellapsed time.
Definition
micro_benchmark_common.h:21
VecEllapsedTime
std::vector< double > VecEllapsedTime
Vector of ellapsed time measurement.
Definition
micro_benchmark_common.h:19
micro_benchmark_rdtsc.h
micro_benchmarkRdtsc
void micro_benchmarkRdtsc(double &ellapsedTimeCy, double &ellapsedTimeErrorCy, size_t nbTestPerf, size_t nbCallPerTest, _Callable &&__f, _Args &&... __args)
Do the micro benchmarking of a given function and gives performance results in cy.
Definition
micro_benchmark_rdtsc_impl.h:22
micro_benchmarkRdtscPrint
void micro_benchmarkRdtscPrint(const std::string &testName, size_t nbTestPerf, size_t nbCallPerTest, size_t nbElement, _Callable &&__f, _Args &&... __args)
Do the micro benchmarking of a given function and gives performance results in cy and print the resul...
Definition
micro_benchmark_rdtsc_impl.h:76
phoenix_timer.h
phoenix_rdtsc
long unsigned int phoenix_rdtsc(void)
src
micro_benchmark_rdtsc_impl.h
Generated by
1.17.0