|
@@ -217,7 +217,7 @@ int main(int argc, char *argv[]) {
|
|
|
long cpptime_nsec, best_cpp;
|
|
|
long ctime_nsec, best_c;
|
|
|
long cpptime_sec, ctime_sec;
|
|
|
- long repeats = 209;
|
|
|
+ long repeats = 150;
|
|
|
//HeapProfilerStart("heapprof");
|
|
|
do {
|
|
|
clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &time1);
|
|
@@ -229,20 +229,23 @@ int main(int argc, char *argv[]) {
|
|
|
cpptime_nsec = diff(time1,time2).tv_nsec;
|
|
|
cpptime_sec = diff(time1,time2).tv_sec;
|
|
|
clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &time1);
|
|
|
- for (int i = 0; i<repeats; ++i) {
|
|
|
- nMie(L, x, m, nt, Theta, &Qext, &Qsca, &Qabs, &Qbk, &Qpr, &g, &Albedo, S1, S2);
|
|
|
- }
|
|
|
+ // for (int i = 0; i<repeats; ++i) {
|
|
|
+ // nMie(L, x, m, nt, Theta, &Qext, &Qsca, &Qabs, &Qbk, &Qpr, &g, &Albedo, S1, S2);
|
|
|
+ // }
|
|
|
clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &time2);
|
|
|
ctime_nsec = diff(time1,time2).tv_nsec;
|
|
|
ctime_sec = diff(time1,time2).tv_sec;
|
|
|
- if ( ctime_sec == 0 && cpptime_sec == 0) {
|
|
|
- printf("-- total repeats: %ld\n", repeats);
|
|
|
- printf("-- C++ time consumed %lg sec\n", (cpptime_nsec/1e9));
|
|
|
- printf("-- C time consumed %lg sec\n", (ctime_nsec/1e9));
|
|
|
- printf("-- C/C++ time ratio: %Lg\n", static_cast<long double>(ctime_nsec)/static_cast<long double>(cpptime_nsec));
|
|
|
- } else {
|
|
|
- printf("==Test is too long!\n");
|
|
|
- }
|
|
|
+ long double ratio = static_cast<long double>(ctime_nsec)
|
|
|
+ /static_cast<long double>(cpptime_nsec);
|
|
|
+ printf("-- C++ time consumed %lg sec\n", (cpptime_nsec/1e9));
|
|
|
+ if ( ratio > 0.01 )
|
|
|
+ if ( ctime_sec == 0 && cpptime_sec == 0) {
|
|
|
+ printf("-- C time consumed %lg sec\n", (ctime_nsec/1e9));
|
|
|
+ printf("-- total repeats: %ld\n", repeats);
|
|
|
+ printf("-- C/C++ time ratio: %Lg\n", ratio);
|
|
|
+ } else {
|
|
|
+ printf("==Test is too long!\n");
|
|
|
+ }
|
|
|
repeats *= 10;
|
|
|
} while (cpptime_nsec < 1e8 && ctime_nsec < 1e8);
|
|
|
|