Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <cmath>
- #include <cstdlib>
- #include "TimeET.h"
- // TimeET from Tekkotsu library:
- // http://hg.tekkotsu.org/Tekkotsu/raw-file/tip/Shared/TimeET.h
- // http://hg.tekkotsu.org/Tekkotsu/raw-file/tip/Shared/TimeET.cc
- using namespace std;
- float randf() { return random()/(float)((1U<<31)-1); }
- int main(int argc, char** argv) {
- const size_t COUNT=1<<25;
- vector<float> n(COUNT+1);
- for(size_t i=0; i<COUNT+1; ++i)
- n[i]=randf()*2*M_PI-M_PI;
- vector<float> o(COUNT);
- TimeET ot;
- for(size_t i=0; i<COUNT; ++i)
- o[i] = 0;
- ot=ot.Age();
- cout << "overhead: " << ot.Value()/COUNT*1e9 << endl;
- vector<float> r1(COUNT);
- TimeET at2;
- for(size_t i=0; i<COUNT; ++i)
- r1[i] = atan2(n[i],n[i+1]);
- cout << "atan2: " << (at2.Age()-ot).Value()/COUNT*1e9 << endl;
- vector<float> r2(COUNT);
- TimeET ac;
- for(size_t i=0; i<COUNT; ++i)
- r2[i] = acos(n[i]);
- cout << "acos: " << (ac.Age()-ot).Value()/COUNT*1e9 << endl;
- vector<float> r3(COUNT);
- TimeET acd;
- for(size_t i=0; i<COUNT; ++i)
- r3[i] = acos(n[i]/n[i+1]);
- cout << "acos/: " << (acd.Age()-ot).Value()/COUNT*1e9 << endl;
- vector<float> r4(COUNT);
- TimeET at;
- for(size_t i=0; i<COUNT; ++i)
- r4[i] = atan(n[i]);
- cout << "atan: " << (at.Age()-ot).Value()/COUNT*1e9 << endl;
- vector<float> r5(COUNT);
- TimeET atd;
- for(size_t i=0; i<COUNT; ++i)
- r5[i] = atan(n[i]/n[i+1]);
- cout << "atan/: " << (atd.Age()-ot).Value()/COUNT*1e9 << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement