#include <stdio.h>
#include <time.h>
#define LOOP1 (100)
#define LOOP2 (480000)
#define LOOP3 (10)
int main( )
{
int a;
clock_t c;
for ( int l = 0 ; l < 2 ; ++ l) {
{
// ぱたん1
a = 0 ;
c = clock ( ) ;
for ( int i( 0 ) ; i < LOOP1; ++ i)
for ( int j( 0 ) ; j < LOOP2; ++ j)
for ( int k( 0 ) ; k < LOOP3; ++ k)
a ^ = k + j + i;
printf ( "%d, time : %d\n " , a, clock ( ) - c) ;
}
{
// ぱたん2
a = 0 ;
c = clock ( ) ;
for ( int i( 0 ) ; i < LOOP1; ++ i)
for ( int j( 0 ) ; j < LOOP3; ++ j)
for ( int k( 0 ) ; k < LOOP2; ++ k)
a ^ = k + j + i;
printf ( "%d, time : %d\n " , a, clock ( ) - c) ;
}
{
// ぱたん3
a = 0 ;
c = clock ( ) ;
int i, j, k;
for ( i = 0 ; i < LOOP1; ++ i)
for ( j = 0 ; j < LOOP2; ++ j)
for ( k = 0 ; k < LOOP3; ++ k)
a ^ = k + j + i;
printf ( "%d, time : %d\n " , a, clock ( ) - c) ;
}
{
// ぱたん4
a = 0 ;
c = clock ( ) ;
int i, j, k;
for ( i = 0 ; i < LOOP1; ++ i)
for ( j = 0 ; j < LOOP3; ++ j)
for ( k = 0 ; k < LOOP2; ++ k)
a ^ = k + j + i;
printf ( "%d, time : %d\n " , a, clock ( ) - c) ;
}
printf ( "\n " ) ;
}
return a;
}
/*
ローカルでの実行結果
0, time : 1766
0, time : 1328
0, time : 1719
0, time : 1390
0, time : 1766
0, time : 1375
0, time : 1672
0, time : 1359
*/
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDx0aW1lLmg+CgojZGVmaW5lIExPT1AxICgxMDApCiNkZWZpbmUgTE9PUDIgKDQ4MDAwMCkKI2RlZmluZSBMT09QMyAoMTApCgppbnQgbWFpbigpCnsKCWludCBhOwoJY2xvY2tfdCBjOwoKCWZvcihpbnQgbCA9IDA7IGwgPCAyOyArK2wpIHsKC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T09QMjsgKytrKQoJCQkJCQlhIF49IGsgKyBqICsgaTsKCQkJcHJpbnRmKCIlZCwgdGltZSA6ICVkXG4iLCBhLCBjbG9jaygpIC0gYyk7CgkJfQoJCgkJcHJpbnRmKCJcbiIpOwoJfQogCglyZXR1cm4gYTsKfQoKLyoK44Ot44O844Kr44Or44Gn44Gu5a6f6KGM57WQ5p6cCgowLCB0aW1lIDogMTc2NgowLCB0aW1lIDogMTMyOAowLCB0aW1lIDogMTcxOQowLCB0aW1lIDogMTM5MAoKMCwgdGltZSA6IDE3NjYKMCwgdGltZSA6IDEzNzUKMCwgdGltZSA6IDE2NzIKMCwgdGltZSA6IDEzNTkKCiovCgo=
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:22: warning: format ‘%d’ expects type ‘int’, but argument 3 has type ‘long int’
prog.cpp:33: warning: format ‘%d’ expects type ‘int’, but argument 3 has type ‘long int’
prog.cpp:45: warning: format ‘%d’ expects type ‘int’, but argument 3 has type ‘long int’
prog.cpp:57: warning: format ‘%d’ expects type ‘int’, but argument 3 has type ‘long int’
stdout
0, time : 460000
0, time : 470000
0, time : 460000
0, time : 620000
0, time : 460000
0, time : 420000
0, time : 460000
0, time : 630000