benchmark_matrix.cpp 548 B

12345678910111213141516171819202122
  1. #include <AP_gbenchmark.h>
  2. #include <AP_Math/AP_Math.h>
  3. static void BM_MatrixMultiplication(benchmark::State& state)
  4. {
  5. Matrix3f m1(Vector3f(1.0f, 2.0f, 3.0f),
  6. Vector3f(4.0f, 5.0f, 6.0f),
  7. Vector3f(7.0f, 8.0f, 9.0f));
  8. Matrix3f m2(Vector3f(1.0f, 2.0f, 3.0f),
  9. Vector3f(4.0f, 5.0f, 6.0f),
  10. Vector3f(7.0f, 8.0f, 9.0f));
  11. while (state.KeepRunning()) {
  12. Matrix3f m3 = m1 * m2;
  13. gbenchmark_escape(&m3);
  14. }
  15. }
  16. BENCHMARK(BM_MatrixMultiplication);
  17. BENCHMARK_MAIN()