From 5b44febe31956b36b62cd3650f7c5249bbe8100c Mon Sep 17 00:00:00 2001 From: Richard Kreckel Date: Fri, 18 Nov 2005 01:14:21 +0000 Subject: [PATCH] * Reworked timing output and increased some timing sizes. --- check/time_antipode.cpp | 2 +- check/time_dennyfliegner.cpp | 6 +++--- check/time_fateman_expand.cpp | 2 +- check/time_gammaseries.cpp | 8 ++++---- check/time_lw_A.cpp | 2 +- check/time_lw_B.cpp | 2 +- check/time_lw_C.cpp | 2 +- check/time_lw_D.cpp | 2 +- check/time_lw_E.cpp | 2 +- check/time_lw_F.cpp | 2 +- check/time_lw_G.cpp | 2 +- check/time_lw_H.cpp | 2 +- check/time_lw_IJKL.cpp | 4 ++-- check/time_lw_M1.cpp | 2 +- check/time_lw_M2.cpp | 2 +- check/time_lw_N.cpp | 2 +- check/time_lw_O.cpp | 4 ++-- check/time_lw_P.cpp | 2 +- check/time_lw_Pprime.cpp | 2 +- check/time_lw_Q.cpp | 2 +- check/time_lw_Qprime.cpp | 2 +- check/time_toeplitz.cpp | 9 +++++---- check/time_vandermonde.cpp | 4 ++-- check/timer.cpp | 13 +++++-------- check/times.cpp | 8 +++++--- 25 files changed, 45 insertions(+), 45 deletions(-) diff --git a/check/time_antipode.cpp b/check/time_antipode.cpp index 670e6c2e..50d43be4 100644 --- a/check/time_antipode.cpp +++ b/check/time_antipode.cpp @@ -496,7 +496,7 @@ unsigned time_antipode() } else { cout << " failed "; } - cout << int(1000*jaeger_le_coultre.read())*0.001 << "s (total)" << endl; + cout << jaeger_le_coultre.read() << "s (total)" << endl; } else { cout << " disabled" << endl; clog << "(no output)" << endl; diff --git a/check/time_dennyfliegner.cpp b/check/time_dennyfliegner.cpp index 8f558a25..b14d1b49 100644 --- a/check/time_dennyfliegner.cpp +++ b/check/time_dennyfliegner.cpp @@ -64,10 +64,10 @@ unsigned time_dennyfliegner() vector times; timer breitling; - sizes.push_back(50); sizes.push_back(100); sizes.push_back(200); sizes.push_back(400); + sizes.push_back(800); for (vector::iterator i=sizes.begin(); i!=sizes.end(); ++i) { breitling.start(); @@ -85,10 +85,10 @@ unsigned time_dennyfliegner() // print the report: cout << endl << " size: "; for (vector::iterator i=sizes.begin(); i!=sizes.end(); ++i) - cout << '\t' << (*i); + cout << '\t' << *i; cout << endl << " time/s:"; for (vector::iterator i=times.begin(); i!=times.end(); ++i) - cout << '\t' << int(1000*(*i))*0.001; + cout << '\t' << *i; cout << endl; return result; diff --git a/check/time_fateman_expand.cpp b/check/time_fateman_expand.cpp index b0a88e22..f78e8215 100644 --- a/check/time_fateman_expand.cpp +++ b/check/time_fateman_expand.cpp @@ -66,7 +66,7 @@ unsigned time_fateman_expand() } else { cout << " failed "; } - cout << int(1000*(time/count))*0.001 << 's' << endl; + cout << time/count << 's' << endl; return result; } diff --git a/check/time_gammaseries.cpp b/check/time_gammaseries.cpp index dd049762..3715f836 100644 --- a/check/time_gammaseries.cpp +++ b/check/time_gammaseries.cpp @@ -54,10 +54,10 @@ unsigned time_gammaseries() vector times; timer omega; - sizes.push_back(10); - sizes.push_back(15); sizes.push_back(20); sizes.push_back(25); + sizes.push_back(30); + sizes.push_back(35); for (vector::iterator i=sizes.begin(); i!=sizes.end(); ++i) { omega.start(); @@ -75,10 +75,10 @@ unsigned time_gammaseries() // print the report: cout << endl << " order: "; for (vector::iterator i=sizes.begin(); i!=sizes.end(); ++i) - cout << '\t' << (*i); + cout << '\t' << *i; cout << endl << " time/s:"; for (vector::iterator i=times.begin(); i!=times.end(); ++i) - cout << '\t' << int(1000*(*i))*0.001; + cout << '\t' << *i; cout << endl; return result; diff --git a/check/time_lw_A.cpp b/check/time_lw_A.cpp index 5df8ac6e..81314552 100644 --- a/check/time_lw_A.cpp +++ b/check/time_lw_A.cpp @@ -60,7 +60,7 @@ unsigned time_lw_A() } else { cout << " failed "; } - cout << int(1000*(time/count))*0.001 << 's' << endl; + cout << time/count << 's' << endl; return result; } diff --git a/check/time_lw_B.cpp b/check/time_lw_B.cpp index eb83bda0..6fe6138c 100644 --- a/check/time_lw_B.cpp +++ b/check/time_lw_B.cpp @@ -61,7 +61,7 @@ unsigned time_lw_B() } else { cout << " failed "; } - cout << int(1000*(time/count))*0.001 << 's' << endl; + cout << time/count << 's' << endl; return result; } diff --git a/check/time_lw_C.cpp b/check/time_lw_C.cpp index c64343f5..e6de1717 100644 --- a/check/time_lw_C.cpp +++ b/check/time_lw_C.cpp @@ -65,7 +65,7 @@ unsigned time_lw_C() } else { cout << " failed "; } - cout << int(1000*(time/count))*0.001 << 's' << endl; + cout << time/count << 's' << endl; return result; } diff --git a/check/time_lw_D.cpp b/check/time_lw_D.cpp index 60e2eb6c..55e25069 100644 --- a/check/time_lw_D.cpp +++ b/check/time_lw_D.cpp @@ -65,7 +65,7 @@ unsigned time_lw_D() } else { cout << " failed "; } - cout << int(1000*(time/count))*0.001 << 's' << endl; + cout << time/count << 's' << endl; return result; } diff --git a/check/time_lw_E.cpp b/check/time_lw_E.cpp index c2a6a811..5a497300 100644 --- a/check/time_lw_E.cpp +++ b/check/time_lw_E.cpp @@ -65,7 +65,7 @@ unsigned time_lw_E() } else { cout << " failed "; } - cout << int(1000*(time/count))*0.001 << 's' << endl; + cout << time/count << 's' << endl; return result; } diff --git a/check/time_lw_F.cpp b/check/time_lw_F.cpp index ad6be8b3..8d8a8934 100644 --- a/check/time_lw_F.cpp +++ b/check/time_lw_F.cpp @@ -62,7 +62,7 @@ unsigned time_lw_F() } else { cout << " failed "; } - cout << int(1000*(time/count))*0.001 << 's' << endl; + cout << time/count << 's' << endl; return result; } diff --git a/check/time_lw_G.cpp b/check/time_lw_G.cpp index 3b6483a3..d0578b61 100644 --- a/check/time_lw_G.cpp +++ b/check/time_lw_G.cpp @@ -65,7 +65,7 @@ unsigned time_lw_G() } else { cout << " failed "; } - cout << int(1000*(time/count))*0.001 << 's' << endl; + cout << time/count << 's' << endl; return result; } diff --git a/check/time_lw_H.cpp b/check/time_lw_H.cpp index 1750616e..efea5761 100644 --- a/check/time_lw_H.cpp +++ b/check/time_lw_H.cpp @@ -77,7 +77,7 @@ unsigned time_lw_H() } else { cout << " failed "; } - cout << int(1000*(time/count))*0.001 << 's' << endl; + cout << time/count << 's' << endl; return result; } diff --git a/check/time_lw_IJKL.cpp b/check/time_lw_IJKL.cpp index 3572d1f7..4d62fedf 100644 --- a/check/time_lw_IJKL.cpp +++ b/check/time_lw_IJKL.cpp @@ -45,7 +45,7 @@ static unsigned test(unsigned n) Hinv = H.inverse(); cout << ". passed "; clog << "(no output)" << endl; - cout << int(1000*cartier.read())*0.001 << 's' << endl; + cout << cartier.read() << 's' << endl; // check result: name = (n==40?'J':(n==70?'L':'?')); @@ -75,7 +75,7 @@ static unsigned test(unsigned n) cout << ". failed "; ++result; } - cout << int(1000*cartier.read())*0.001 << 's' << endl; + cout << cartier.read() << 's' << endl; return result; } diff --git a/check/time_lw_M1.cpp b/check/time_lw_M1.cpp index 597a4a72..8ac2c25b 100644 --- a/check/time_lw_M1.cpp +++ b/check/time_lw_M1.cpp @@ -97,7 +97,7 @@ unsigned time_lw_M1() } else { cout << " failed "; } - cout << int(1000*(time/count))*0.001 << 's' << endl; + cout << time/count << 's' << endl; return result; } diff --git a/check/time_lw_M2.cpp b/check/time_lw_M2.cpp index aa1178a3..04218b72 100644 --- a/check/time_lw_M2.cpp +++ b/check/time_lw_M2.cpp @@ -174,7 +174,7 @@ unsigned time_lw_M2() } else { cout << " failed "; } - cout << int(1000*(time/count))*0.001 << 's' << endl; + cout << time/count << 's' << endl; } else { cout << " disabled" << endl; clog << "(no output)" << endl; diff --git a/check/time_lw_N.cpp b/check/time_lw_N.cpp index 77e91a72..36f219d5 100644 --- a/check/time_lw_N.cpp +++ b/check/time_lw_N.cpp @@ -77,7 +77,7 @@ unsigned time_lw_N() } else { cout << " failed "; } - cout << int(1000*(time/count))*0.001 << 's' << endl; + cout << time/count << 's' << endl; } else { cout << " disabled" << endl; clog << "(no output)" << endl; diff --git a/check/time_lw_O.cpp b/check/time_lw_O.cpp index 254b39b0..5ae917a5 100644 --- a/check/time_lw_O.cpp +++ b/check/time_lw_O.cpp @@ -148,7 +148,7 @@ unsigned time_lw_O() } else { cout << " failed "; } - cout << int(1000*(time/(3*count)))*0.001 << "s (average)" << endl; + cout << time/(3*count) << "s (average)" << endl; cout << "timing Lewis-Wester test O2 (Resultant)" << flush; clog << "-------Lewis-Wester test O2 (Resultant):" << endl; @@ -163,7 +163,7 @@ unsigned time_lw_O() } else { cout << " failed "; } - cout << int(1000*rolex.read())*0.001 << "s (combined)" << endl; + cout << rolex.read() << "s (combined)" << endl; } else { cout << " disabled" << endl; clog << "(no output)" << endl; diff --git a/check/time_lw_P.cpp b/check/time_lw_P.cpp index 52a430d8..e0270d29 100644 --- a/check/time_lw_P.cpp +++ b/check/time_lw_P.cpp @@ -75,7 +75,7 @@ unsigned time_lw_P() } else { cout << " failed "; } - cout << int(1000*(time/count))*0.001 << 's' << endl; + cout << time/count << 's' << endl; return result; } diff --git a/check/time_lw_Pprime.cpp b/check/time_lw_Pprime.cpp index 19b05591..9a5a04b0 100644 --- a/check/time_lw_Pprime.cpp +++ b/check/time_lw_Pprime.cpp @@ -88,7 +88,7 @@ unsigned time_lw_Pprime() } else { cout << " failed "; } - cout << int(1000*(time/count))*0.001 << 's' << endl; + cout << time/count << 's' << endl; return result; } diff --git a/check/time_lw_Q.cpp b/check/time_lw_Q.cpp index 2a067693..7fb54f91 100644 --- a/check/time_lw_Q.cpp +++ b/check/time_lw_Q.cpp @@ -79,7 +79,7 @@ unsigned time_lw_Q() } else { cout << " failed "; } - cout << int(1000*(time/count))*0.001 << 's' << endl; + cout << time/count << 's' << endl; } else { cout << " disabled" << endl; clog << "(no output)" << endl; diff --git a/check/time_lw_Qprime.cpp b/check/time_lw_Qprime.cpp index 4abedd1a..28b30ca9 100644 --- a/check/time_lw_Qprime.cpp +++ b/check/time_lw_Qprime.cpp @@ -91,7 +91,7 @@ unsigned time_lw_Qprime() } else { cout << " failed "; } - cout << int(1000*(time/count))*0.001 << 's' << endl; + cout << time/count << 's' << endl; } else { cout << " disabled" << endl; clog << "(no output)" << endl; diff --git a/check/time_toeplitz.cpp b/check/time_toeplitz.cpp index 20c9a13a..8c2008ab 100644 --- a/check/time_toeplitz.cpp +++ b/check/time_toeplitz.cpp @@ -29,7 +29,7 @@ static unsigned toeplitz_det(unsigned size) { unsigned result = 0; const symbol a("a"), b("b"); - ex p[9] = {ex("a",lst(a,b)), + ex p[10] = {ex("a",lst(a,b)), ex("b",lst(a,b)), ex("a+b",lst(a,b)), ex("a^2+a*b+b^2",lst(a,b)), @@ -37,7 +37,8 @@ static unsigned toeplitz_det(unsigned size) ex("a^4+a^3*b+a^2*b^2+a*b^3+b^4",lst(a,b)), ex("a^5+a^4*b+a^3*b^2-a^2*b^3+a*b^4+b^5",lst(a,b)), ex("a^6+a^5*b+a^4*b^2+a^3*b^3+a^2*b^4+a*b^5+b^6",lst(a,b)), - ex("a^7+a^6*b+a^5*b^2+a^4*b^3-a^3*b^4+a^2*b^5+a*b^6+b^7",lst(a,b)) + ex("a^7+a^6*b+a^5*b^2+a^4*b^3-a^3*b^4+a^2*b^5+a*b^6+b^7",lst(a,b)), + ex("a^8+a^7*b+a^6*b^2+a^5*b^3+a^4*b^4+a^3*b^5+a^2*b^6+a*b^7+b^8",lst(a,b)) }; // construct Toeplitz matrix (diagonal structure: [[x,y,z],[y,x,y],[z,y,x]]): @@ -74,10 +75,10 @@ unsigned time_toeplitz() vector times; timer longines; - sizes.push_back(6); sizes.push_back(7); sizes.push_back(8); sizes.push_back(9); + sizes.push_back(10); for (vector::iterator i=sizes.begin(); i!=sizes.end(); ++i) { int count = 1; @@ -104,7 +105,7 @@ unsigned time_toeplitz() cout << '\t' << *i << 'x' << *i; cout << endl << " time/s:"; for (vector::iterator i=times.begin(); i!=times.end(); ++i) - cout << '\t' << int(1000*(*i))*0.001; + cout << '\t' << *i; cout << endl; return result; diff --git a/check/time_vandermonde.cpp b/check/time_vandermonde.cpp index 3516ef6d..d4f94921 100644 --- a/check/time_vandermonde.cpp +++ b/check/time_vandermonde.cpp @@ -72,10 +72,10 @@ unsigned time_vandermonde() vector times; timer swatch; - sizes.push_back(6); sizes.push_back(8); sizes.push_back(10); sizes.push_back(12); + sizes.push_back(14); for (vector::iterator i=sizes.begin(); i!=sizes.end(); ++i) { int count = 1; @@ -102,7 +102,7 @@ unsigned time_vandermonde() cout << '\t' << *i << 'x' << *i; cout << endl << " time/s:"; for (vector::iterator i=times.begin(); i!=times.end(); ++i) - cout << '\t' << int(1000*(*i))*0.001; + cout << '\t' << *i; cout << endl; return result; diff --git a/check/timer.cpp b/check/timer.cpp index b6c3a6b8..0723b8a9 100644 --- a/check/timer.cpp +++ b/check/timer.cpp @@ -86,18 +86,15 @@ double timer::read() #ifdef HAVE_RUSAGE if (running()) getrusage(RUSAGE_SELF, &used2); - elapsed = ((used2.ru_utime.tv_sec - used1.ru_utime.tv_sec) + - (used2.ru_stime.tv_sec - used1.ru_stime.tv_sec) + - (used2.ru_utime.tv_usec - used1.ru_utime.tv_usec) * 1e-6 + - (used2.ru_stime.tv_usec - used1.ru_stime.tv_usec) * 1e-6); + return ((used2.ru_utime.tv_sec - used1.ru_utime.tv_sec) + + (used2.ru_stime.tv_sec - used1.ru_stime.tv_sec) + + (used2.ru_utime.tv_usec - used1.ru_utime.tv_usec) * 1e-6 + + (used2.ru_stime.tv_usec - used1.ru_stime.tv_usec) * 1e-6); #else if (running()) used2 = clock(); - elapsed = double(used2 - used1)/CLOCKS_PER_SEC; + return double(used2 - used1)/CLOCKS_PER_SEC; #endif - // Results more accurate than 10ms are pointless: - return elapsed; - return 0.01*int(elapsed*100+0.5); } bool timer::running() diff --git a/check/times.cpp b/check/times.cpp index 8db2c0c6..93d0e131 100644 --- a/check/times.cpp +++ b/check/times.cpp @@ -40,11 +40,10 @@ */ void randomify_symbol_serials() { - srand((unsigned)time(NULL)); + srand(time(NULL)); const int m = rand() % 666; for (int s=0; s