// powtest.cpp : Defines the entry point for the console application. // //#pragma inline_depth (255) //#pragma inline_recursion(on ) //#pragma auto_inline( on ) #define Z_MATH #define C_MATH #include "stdafx.h" #ifdef C_MATH #include #endif #include #include #ifdef Z_MATH namespace Math { template struct Loop { inline static void exec() { _asm{fmul st(0),st(1)} Loop::exec(); } }; struct Loop<0> { inline static void exec(){} }; template inline static T Pow(T x) { _asm{fld x} _asm{fld st(0)} Loop::exec(); _asm{fstp st(1)} _asm{fstp x} return x; } } #endif int main(int argc, char* argv[]) { Sleep(1); #define TLOOP 15000000 double y = 0; double x; long ticks; long ticks2; long tickCount; #ifdef C_MATH ticks = GetTickCount(); for(x=0;x<=TLOOP;x++) { y=pow(x,3.0); } ticks2 = GetTickCount(); tickCount = ticks2 - ticks; printf("Ticks Elapsed for math.h pow: %.2ld\t\ty = %.4f\n",tickCount,y); #endif y = 0; double fx; double dy; #ifdef Z_MATH ticks = GetTickCount(); for(fx=0;fx<=TLOOP;fx++) { dy = Math::Pow(fx); } ticks2 = GetTickCount(); tickCount = ticks2 - ticks; printf("Ticks Elapsed for Math::Pow: %.2ld\t\ty = %.4f\n",tickCount,dy); #endif return 0; }