GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: TESTS/HadamardProductNbTest/main.cpp Lines: 21 21 100.0 %
Date: 2025-03-16 06:08:08 Branches: 12 18 66.7 %

Line Branch Exec Source
1
/***************************************
2
	Auteur : Pierre Aubert
3
	Mail : pierre.aubert@lapp.in2p3.fr
4
	Licence : CeCILL-C
5
****************************************/
6
7
#include "micro_benchmark.h"
8
9
///Do the Hadamard product
10
/**	@param[out] tabResult : table of results of tabX*tabY
11
 * 	@param tabX : input table
12
 * 	@param tabY : input table
13
 * 	@param nbElement : number of elements in the tables
14
*/
15
184800
void hadamard_product(float* tabResult, const float* tabX, const float* tabY, size_t nbElement){
16
770184800
	for(size_t i(0lu); i < nbElement; ++i){
17
770000000
		tabResult[i] = tabX[i]*tabY[i];
18
	}
19
184800
}
20
21
///Get the number of nanoseconds per elements of the Hadamard product
22
/**	@param nbElement : number of elements in tables for performance evaluation
23
*/
24
66
void evaluateHadamardProductNbTest(size_t nbElement){
25
	//Allocation of the tables
26
66
	float * tabResult = new float[nbElement];
27
66
	float * tabX = new float[nbElement];
28
66
	float * tabY = new float[nbElement];
29
	//Initialisation of the tables
30
275066
	for(size_t i(0lu); i < nbElement; ++i){
31
275000
		tabX[i] = (float)(i*32lu%17lu);
32
275000
		tabY[i] = (float)(i*57lu%31lu);
33
	}
34
66
	size_t nbTestPerf(NB_TEST_PERF);
35
66
	size_t nbCallPerTest(10lu);
36
66
	size_t fullNbElement(nbElement);
37
	//Stating the timer
38
66
	micro_benchmarkNsPrint("evaluateHadamardProductNbTest",
39
			nbTestPerf, nbCallPerTest, fullNbElement, hadamard_product,
40
			tabResult, tabX, tabY, nbElement);
41
42
	//Deallocate the tables
43
66
	delete[] tabResult;
44
66
	delete[] tabX;
45
66
	delete[] tabY;
46
66
}
47
48
11
int main(int argc, char** argv){
49
11
	return micro_benchmarkParseArg(argc, argv, evaluateHadamardProductNbTest);
50
}
51