All pastes #187433 Raw Edit

Someone

public text v1 · immutable
·published 2006-10-01 02:53 UTC
rendered paste body
#include <iostream>
#include <math.h>
#include <windows.h>

double my_cos(double x){
  const double one_over_2=1.0/2;
  const double one_over_24=1.0/24;
  const double one_over_720=1.0/720;
  const double one_over_40320=1.0/40320;
  double x2=x*x;
  double x4=x2*x2;
  return 1.0-one_over_2*x2+x4*(one_over_24-x2*one_over_720+x4*one_over_40320);
} 

int main()
{
	system("pause");
	
	SetPriorityClass(GetCurrentThread(), REALTIME_PRIORITY_CLASS);
	SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL);

	DWORD tick = GetTickCount();
	int i;
	for(i=0; i < 1000000; ++i)
	{
		my_cos(1.0);
		my_cos(1.0);
		my_cos(1.0);
		my_cos(1.0);
		my_cos(1.0);
		my_cos(1.0);
		my_cos(1.0);
		my_cos(1.0);
		my_cos(1.0);
		my_cos(1.0);
		my_cos(1.0);
		my_cos(1.0);
		my_cos(1.0);
		my_cos(1.0);
		my_cos(1.0);
		my_cos(1.0);
		my_cos(1.0);
		my_cos(1.0);
		my_cos(1.0);
		my_cos(1.0);
	}
	tick = GetTickCount() - tick;
	std::cout << tick << std::endl;

	tick = GetTickCount();
	for(i=0; i < 1000000; ++i)
	{
		cos(1.0);
		cos(1.0);
		cos(1.0);
		cos(1.0);
		cos(1.0);
		cos(1.0);
		cos(1.0);
		cos(1.0);
		cos(1.0);
		cos(1.0);
		cos(1.0);
		cos(1.0);
		cos(1.0);
		cos(1.0);
		cos(1.0);
		cos(1.0);
		cos(1.0);
		cos(1.0);
		cos(1.0);
		cos(1.0);
	}
	tick = GetTickCount() - tick;
	std::cout << tick << std::endl;

	return 0;
}