View difference between Paste ID: 03s3Kvry and
SHOW: | | - or go back to the newest paste.
1-
1+
#include <time.h>
2
#include <cstdlib>
3
#include <iostream>
4
#include <vector>
5
6
using namespace std;
7
8
//#define MANUAL_INLINE
9
10
#if 1
11
12
#if 1
13
#define FORCE_INLINE1 __forceinline
14
#define FORCE_INLINE2 
15
#else
16
#define FORCE_INLINE1 
17
#define FORCE_INLINE2 __attribute__((always_inline))
18
#endif
19
20
#endif
21
22
struct ASD  {
23
	float e;
24
25
	ASD(float e)
26
		:e(e)
27
	{}
28
29
	FORCE_INLINE1 bool test(const ASD& y)const FORCE_INLINE2 {
30
		return e<y.e;
31
	}
32
};
33
34
int main(){
35
	
36
#ifdef MANUAL_INLINE		
37
	freopen( "manual"	,"w",stdout);
38
#else
39
	freopen( "compiler"	,"w",stdout);
40
#endif
41
42
43
	srand(time(NULL));
44
	
45
	ASD& a=*new ASD((float)(rand())/RAND_MAX);
46
	ASD& b=*new ASD(2.0+(float)(rand())/RAND_MAX);
47
48
	clock_t start,end;
49
	const int N=50,n=100000000;
50
51
	int *asd=new int[16];
52
	vector<double> times;
53
54
	for(int i=0;i<N;i++){
55
56
		start = clock();
57
58
		for(int j=n;--j>0;)
59
#ifdef MANUAL_INLINE
60
			asd[j%16]=a.e<b.e;
61
#else
62
			asd[j%16]=a.test(b);
63
#endif
64
65
		end = clock();
66
		times.push_back(double(n)/(end - start));
67
	}
68
	for(int i=0;i<times.size();i++)
69
		cout<<i<<" "<<times[i]<<endl;
70
71
	return 0;
72
}