GCC Code Coverage Report


Directory: ./
File: src/PFunctionTimer_impl.h
Date: 2026-08-21 15:39:57
Exec Total Coverage
Lines: 17 17 100.0%
Functions: 1 1 100.0%
Branches: 3 4 75.0%

Line Branch Exec Source
1
2 /***************************************
3 Auteur : Pierre Aubert
4 Mail : pierre.aubert@lapp.in2p3.fr
5 Licence : CeCILL-C
6 ****************************************/
7
8 #ifndef __PFUNCTIONTIMER_IMPL_H__
9 #define __PFUNCTIONTIMER_IMPL_H__
10
11 #include "pin_thread_to_core.h"
12 #include "micro_benchmark_ns.h"
13 #include "PFunctionTimer.h"
14
15 ///Prevent compiler from optimising a loop
16 /** @param value : reference to a value
17 */
18 template <class T>
19 101 [[gnu::always_inline]] inline void benchmark_doNotOptimize(T & value) {
20 #if defined(__clang__)
21 asm volatile("" : "+r,m"(value) : : "memory");
22 #else
23 201 asm volatile("" : "+m,r"(value) : : "memory");
24 #endif
25 }
26
27 ///Method which evaluate performance of the given function
28 /** @param __f : function to be evaluated
29 * @param __args : arguments of the function
30 * The function will be called nbMeasure times (set by the resize method)
31 */
32 template<typename _Callable, typename... _Args>
33 1 void PFunctionTimer::evalPerf(_Callable&& __f, _Args&&... __args){
34
1/2
✗ Branch 0 (3→4) not taken.
✓ Branch 1 (3→5) taken 1 times.
1 PIN_THREAD_TO_CORE
35 1 int dummy = 0;
36 1 ::benchmark_doNotOptimize(dummy);
37
2/2
✓ Branch 0 (14→7) taken 100 times.
✓ Branch 1 (14→15) taken 1 times.
101 for(size_t i(0lu); i < p_nbMeasure; ++i){
38 //Start chrono
39 100 HiPeTime startNs = phoenix_getTime();
40 100 size_t startCy = phoenix_rdtsc();
41 //Call function
42 100 ::benchmark_doNotOptimize(dummy);
43 100 __f(__args...);
44 //Compute ellapsed time
45 100 size_t ellapsedTimeCy(phoenix_rdtsc() - startCy);
46 100 p_vecEllapsedTimeNs[i] = (double)ellapsedTimeCy;
47 100 NanoSecs elapsedTimeNs(phoenix_getTime() - startNs);
48 100 double fullNs((double)elapsedTimeNs.count());
49 100 p_vecEllapsedTimeCycle[i] = fullNs;
50 }
51 1 }
52
53 //{Finally we close the header :
54 #endif
55
56