GCC Code Coverage Report


Directory: ./
File: TESTS/TEST_FUNCTION_TIMER/main.cpp
Date: 2026-08-21 15:39:57
Exec Total Coverage
Lines: 20 20 100.0%
Functions: 3 3 100.0%
Branches: 19 32 59.4%

Line Branch Exec Source
1 /***************************************
2 Auteur : Pierre Aubert
3 Mail : pierre.aubert@lapp.in2p3.fr
4 Licence : CeCILL-C
5 ****************************************/
6
7 #include <cassert>
8 #include "PFunctionTimer.h"
9
10 typedef std::vector<float> VecData;
11
12 ///Do the Hadamard product
13 /** @param[out] tabResult : table of results of tabX*tabY
14 * @param tabX : input table
15 * @param tabY : input table
16 * @param nbElement : number of elements in the tables
17 */
18 100 void hadamard_product(VecData & tabResult, const VecData & tabX, const VecData & tabY){
19
1/2
✗ Branch 0 (2→3) not taken.
✓ Branch 1 (2→4) taken 100 times.
100 size_t nbElement(tabX.size());
20
2/4
✗ Branch 0 (4→5) not taken.
✓ Branch 1 (4→6) taken 100 times.
✗ Branch 2 (6→7) not taken.
✓ Branch 3 (6→8) taken 100 times.
100 assert(tabY.size() == nbElement);
21
2/4
✗ Branch 0 (8→9) not taken.
✓ Branch 1 (8→10) taken 100 times.
✗ Branch 2 (10→11) not taken.
✓ Branch 3 (10→13) taken 100 times.
100 assert(tabResult.size() == nbElement);
22
2/2
✓ Branch 0 (13→12) taken 10000000 times.
✓ Branch 1 (13→14) taken 100 times.
10000100 for(size_t i(0lu); i < nbElement; ++i){
23 10000000 tabResult[i] = tabX[i]*tabY[i];
24 }
25 100 }
26
27 ///Test the function timer on a Hadamard Product
28 /** @return true on success, false otherwise
29 */
30 1 bool testFunctionTimer(){
31 1 size_t nbElement(100000lu);
32 //Allocation of the tables
33
2/6
✓ Branch 0 (3→4) taken 1 times.
✓ Branch 2 (4→5) taken 1 times.
✗ Branch 4 (40→41) not taken.
✗ Branch 5 (40→43) not taken.
✗ Branch 6 (44→45) not taken.
✗ Branch 7 (44→47) not taken.
1 VecData vecX(nbElement), vecY(nbElement), vecRes(nbElement);
34 //Initialisation of the tables
35
2/2
✓ Branch 0 (7→6) taken 100000 times.
✓ Branch 1 (7→8) taken 1 times.
100001 for(size_t i(0lu); i < nbElement; ++i){
36 100000 vecX[i] = (float)(i*32lu%17lu);
37 100000 vecY[i] = (float)(i*57lu%31lu);
38 }
39
1/1
✓ Branch 0 (8→9) taken 1 times.
1 PFunctionTimer timer(100lu, nbElement);
40
1/1
✓ Branch 0 (9→10) taken 1 times.
1 timer.evalPerf(hadamard_product, vecRes, vecX, vecY);
41
3/4
✓ Branch 0 (10→11) taken 1 times.
✓ Branch 2 (11→12) taken 1 times.
✗ Branch 4 (12→13) not taken.
✓ Branch 5 (12→15) taken 1 times.
1 return timer.savePerf("perf_hadamard_product.toml");
42
3/6
✓ Branch 0 (18→19) taken 1 times.
✗ Branch 1 (18→21) not taken.
✓ Branch 2 (21→22) taken 1 times.
✗ Branch 3 (21→24) not taken.
✓ Branch 4 (24→25) taken 1 times.
✗ Branch 5 (24→27) not taken.
4 }
43
44 1 int main(int argc, char** argv){
45 1 bool b(testFunctionTimer());
46 1 return b - 1;
47 }
48
49