Created
August 29, 2012 14:24
-
-
Save aoisensi/3513320 to your computer and use it in GitHub Desktop.
OperatorSpeed
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <time.h> | |
using namespace std; | |
const double pi = 3.14159265F; | |
const double s2 = 1.41421356F; | |
const int n = 1000000000; | |
int main() | |
{ | |
int a = clock(); | |
double r; | |
for(int i=0;i<n;++i) | |
{ | |
double r = pi + s2; | |
} | |
int b = clock(); | |
for(int i=0;i<n;++i) | |
{ | |
double r = pi - s2; | |
} | |
int c = clock(); | |
for(int i=0;i<n;++i) | |
{ | |
double r = pi * s2; | |
} | |
int d = clock(); | |
for(int i=0;i<n;++i) | |
{ | |
double r = pi / s2; | |
} | |
int e = clock(); | |
cout << "add " << b-a << endl; | |
cout << "sub " << c-b << endl; | |
cout << "mul " << d-c << endl; | |
cout << "div " << e-d << endl; | |
getchar(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment