MCPcopy Create free account
hub / github.com/PX4/eigen / bench_reverse

Function bench_reverse

bench/bench_reverse.cpp:18–58  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

16
17template <typename MatrixType>
18__attribute__ ((noinline)) void bench_reverse(const MatrixType& m)
19{
20 int rows = m.rows();
21 int cols = m.cols();
22 int size = m.size();
23
24 int repeats = (REPEAT*1000)/size;
25 MatrixType a = MatrixType::Random(rows,cols);
26 MatrixType b = MatrixType::Random(rows,cols);
27
28 BenchTimer timerB, timerH, timerV;
29
30 Scalar acc = 0;
31 int r = internal::random<int>(0,rows-1);
32 int c = internal::random<int>(0,cols-1);
33 for (int t=0; t<TRIES; ++t)
34 {
35 timerB.start();
36 for (int k=0; k<repeats; ++k)
37 {
38 asm("#begin foo");
39 b = a.reverse();
40 asm("#end foo");
41 acc += b.coeff(r,c);
42 }
43 timerB.stop();
44 }
45
46 if (MatrixType::RowsAtCompileTime==Dynamic)
47 std::cout << "dyn ";
48 else
49 std::cout << "fixed ";
50 std::cout << rows << " x " << cols << " \t"
51 << (timerB.value() * REPEAT) / repeats << "s "
52 << "(" << 1e-6 * size*repeats/timerB.value() << " MFLOPS)\t";
53
54 std::cout << "\n";
55 // make sure the compiler does not optimize too much
56 if (acc==123)
57 std::cout << acc;
58}
59
60int main(int argc, char* argv[])
61{

Callers 1

mainFunction · 0.85

Calls 8

rowsMethod · 0.45
colsMethod · 0.45
sizeMethod · 0.45
startMethod · 0.45
reverseMethod · 0.45
coeffMethod · 0.45
stopMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected