diff options
author | Johan Jansen <jnsn.johan@gmail.com> | 2015-03-17 14:08:20 +0100 |
---|---|---|
committer | Johan Jansen <jnsn.johan@gmail.com> | 2015-03-17 14:08:20 +0100 |
commit | 3451a4686af81b1ef7fde21e9ef79b21163de09c (patch) | |
tree | 0e0bec525bc1aad8178c18bfaf64ee8198698ce8 /src/systemcmds/tests/test_eigen.cpp | |
parent | 008a36003f4bf3ca031bd4473597a4892727dba2 (diff) | |
download | px4-firmware-3451a4686af81b1ef7fde21e9ef79b21163de09c.tar.gz px4-firmware-3451a4686af81b1ef7fde21e9ef79b21163de09c.tar.bz2 px4-firmware-3451a4686af81b1ef7fde21e9ef79b21163de09c.zip |
test_eigen: Make TEST_OP macro more readable
Diffstat (limited to 'src/systemcmds/tests/test_eigen.cpp')
-rw-r--r-- | src/systemcmds/tests/test_eigen.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/systemcmds/tests/test_eigen.cpp b/src/systemcmds/tests/test_eigen.cpp index ed04d39a1..767ea2d87 100644 --- a/src/systemcmds/tests/test_eigen.cpp +++ b/src/systemcmds/tests/test_eigen.cpp @@ -54,7 +54,16 @@ namespace Eigen typedef Matrix<float, 10, 1> Vector10f; } -#define TEST_OP(_title, _op) { size_t n = 60000; hrt_abstime t0, t1; t0 = hrt_absolute_time(); for (size_t j = 0; j < n; j++) { _op; }; t1 = hrt_absolute_time(); warnx(_title ": %.6fus", (double)(t1 - t0) / n); } +static constexpr size_t OPERATOR_ITERATIONS = 60000; + +#define TEST_OP(_title, _op) \ +{ \ + const hrt_abstime t0 = hrt_absolute_time(); \ + for (size_t j = 0; j < OPERATOR_ITERATIONS; j++) { \ + _op; \ + } \ + printf(_title ": %.6fus", static_cast<double>(hrt_absolute_time() - t0) / OPERATOR_ITERATIONS); \ +} /** * @brief @@ -160,7 +169,7 @@ int test_eigen(int argc, char *argv[]) TEST_OP("Vector<4> - Vector<4>", v - v1); TEST_OP("Vector<4> += Vector<4>", v += v1); TEST_OP("Vector<4> -= Vector<4>", v -= v1); - TEST_OP("Vector<4> * Vector<4>", v.dot(v1)); + TEST_OP("Vector<4> dot Vector<4>", v.dot(v1)); } { |