Skip to content

Instantly share code, notes, and snippets.

@aoisensi
Created August 29, 2012 14:24
Show Gist options
  • Save aoisensi/3513320 to your computer and use it in GitHub Desktop.
Save aoisensi/3513320 to your computer and use it in GitHub Desktop.
OperatorSpeed
#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