Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <time.h>
- #include <cstdlib>
- #include <iostream>
- #include <vector>
- using namespace std;
- //#define MANUAL_INLINE
- #if 1
- #if 1
- #define FORCE_INLINE1 __forceinline
- #define FORCE_INLINE2
- #else
- #define FORCE_INLINE1
- #define FORCE_INLINE2 __attribute__((always_inline))
- #endif
- #endif
- struct ASD {
- float e;
- ASD(float e)
- :e(e)
- {}
- FORCE_INLINE1 bool test(const ASD& y)const FORCE_INLINE2 {
- return e<y.e;
- }
- };
- int main(){
- #ifdef MANUAL_INLINE
- freopen( "manual" ,"w",stdout);
- #else
- freopen( "compiler" ,"w",stdout);
- #endif
- srand(time(NULL));
- ASD& a=*new ASD((float)(rand())/RAND_MAX);
- ASD& b=*new ASD(2.0+(float)(rand())/RAND_MAX);
- clock_t start,end;
- const int N=50,n=100000000;
- int *asd=new int[16];
- vector<double> times;
- for(int i=0;i<N;i++){
- start = clock();
- for(int j=n;--j>0;)
- #ifdef MANUAL_INLINE
- asd[j%16]=a.e<b.e;
- #else
- asd[j%16]=a.test(b);
- #endif
- end = clock();
- times.push_back(double(n)/(end - start));
- }
- for(int i=0;i<times.size();i++)
- cout<<i<<" "<<times[i]<<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement