[llvm-commits] [test-suite] r169914 - /test-suite/trunk/SingleSource/Benchmarks/Misc-C++/stepanov_v1p2.cpp
Daniel Dunbar
daniel at zuster.org
Tue Dec 11 13:16:50 PST 2012
Author: ddunbar
Date: Tue Dec 11 15:16:50 2012
New Revision: 169914
URL: http://llvm.org/viewvc/llvm-project?rev=169914&view=rev
Log:
stepanov_v1p2: Fix a possible non-determism if subsequent clock() calls return
an identical value.
- In such a case this test could divide by 0 and end up printing an inf.
Modified:
test-suite/trunk/SingleSource/Benchmarks/Misc-C++/stepanov_v1p2.cpp
Modified: test-suite/trunk/SingleSource/Benchmarks/Misc-C++/stepanov_v1p2.cpp
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Benchmarks/Misc-C%2B%2B/stepanov_v1p2.cpp?rev=169914&r1=169913&r2=169914&view=diff
==============================================================================
--- test-suite/trunk/SingleSource/Benchmarks/Misc-C++/stepanov_v1p2.cpp (original)
+++ test-suite/trunk/SingleSource/Benchmarks/Misc-C++/stepanov_v1p2.cpp Tue Dec 11 15:16:50 2012
@@ -67,6 +67,7 @@
#include <time.h>
#include <math.h>
#include <stdlib.h>
+#include <float.h>
template <class T>
inline int operator!=(const T& x, const T& y) {
@@ -243,7 +244,10 @@
inline double timer() {
end_time = clock();
- return (end_time - start_time)/double(CLOCKS_PER_SEC);
+
+ /* The FLT_EPSILON addition is an llvm hack to ensure timer() never returns
+ * 0.0 (we divide by it later). */
+ return FLT_EPSILON + (end_time - start_time)/double(CLOCKS_PER_SEC);
}
const double init_value = 3.;
More information about the llvm-commits
mailing list