From 15740faf9fe9fe4be08965098bbf2947e096aeeb Mon Sep 17 00:00:00 2001 From: chai Date: Wed, 14 Aug 2019 22:50:43 +0800 Subject: +Unity Runtime code --- .../MathPerformanceTest/MatrixMultiplyTest.cpp | 166 +++++++++++++++++++++ 1 file changed, 166 insertions(+) create mode 100644 Runtime/Testing/MathPerformanceTest/MatrixMultiplyTest.cpp (limited to 'Runtime/Testing/MathPerformanceTest/MatrixMultiplyTest.cpp') diff --git a/Runtime/Testing/MathPerformanceTest/MatrixMultiplyTest.cpp b/Runtime/Testing/MathPerformanceTest/MatrixMultiplyTest.cpp new file mode 100644 index 0000000..8e3c2c7 --- /dev/null +++ b/Runtime/Testing/MathPerformanceTest/MatrixMultiplyTest.cpp @@ -0,0 +1,166 @@ +#include "UnityPrefix.h" +#include "Runtime/Testing/Testing.h" + +#if ENABLE_PERFORMANCE_TESTS + +#include "Runtime/Math/Matrix4x4.h" +#include "Runtime/Profiler/TimeHelper.h" + +extern void MultiplyMatrices4x4REF (const Matrix4x4f* __restrict lhs, const Matrix4x4f* __restrict rhs, Matrix4x4f* __restrict res); +extern void MultiplyMatrices4x4SSE (const Matrix4x4f* __restrict lhs, const Matrix4x4f* __restrict rhs, Matrix4x4f* __restrict res); + +extern void CopyMatrixREF( const float* __restrict lhs, float* __restrict res); +extern void CopyMatrixSSE( const float* __restrict lhs, float* __restrict res); + +#define ITERATIONS_COUNT 10000 + + +/* + one of the good results ( launched with Shift+F5 in release mode ): + ITERATIONS_COUNT: 10000 + timeElapsedREF: 1393 + timeElapsedSSE: 639 + timeElapsedJOE: 647 + total cycles REF: 1423390 + total cycles SSE: 650381 + total cycles JOE: 660177 + avg cycles REF: 142 + avg cycles SSE: 65 + avg cycles JOE: 66 + + + Matrix Copy: Ref vs SSE + ITERATIONS_COUNT=10000 + time elapsedCPY: 2114 + time elapsedCPYSSE: 964 + total cycles CPY: 2157582 + total cycles CPYSSE: 980763 + avg cycles CPY: 215 + avg cycles CPYSSE: 98 + ctrl:20000.000000 + +*/ + + +void TestMultiplyMatrices() +{ + Matrix4x4f m0, m1, m2; +#define RESET_MATS() for(int i=0;i<16;i++) { m0.m_Data[i] = (float)(i+1); m1.m_Data[15-i] = (float)(i+1); } + + + RESET_MATS(); + + ABSOLUTE_TIME startTimeREF = GetStartTime(); + UInt64 cycStartREF = __rdtsc(); + for(UInt32 i=0;i