Guest User

Untitled

a guest
Mar 28th, 2012
51
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. inline float __declspec(naked) __fastcall Sin(float angle) {
  2.     _asm {
  3.         fld dword ptr[esp+4]
  4.         fmul dword ptr[ToRadians]
  5.         fsin
  6.         ret 4
  7.     }
  8. }
  9. //...
  10.     float f = 0.0f;
  11.     float angle = 0.0f;
  12. BEGIN_PROFILE("StdSin");
  13.     for(int i = 0; i < tests; i++) {
  14.  
  15.         f *= std::sin(angle * ToRadians);
  16.         angle ++;
  17.     }
  18. END_PROFILE("StdSin");
  19.     angle = 0.0f;
  20. BEGIN_PROFILE("MySin");
  21.     for(int j = 0; j < tests; j++) {
  22.         f *= Sin(angle);
  23.         angle ++;
  24.     }
  25. END_PROFILE("MySin");
  26.     angle = 0.0f;
  27.  
  28.     double t1 = Profiling->FindProfilerInfo("StdSin").AvgTime;          //65
  29.     double t2 = Profiling->FindProfilerInfo("MySin").AvgTime;           //35
RAW Paste Data