Somewhat address @jroelofs comments. The timers are enabled by default EXCEPT
when using LIT. Since there is currently no way in LIT to show the output it
doesn't make sense to introduce the `<chrono>` dependency.
http://reviews.llvm.org/D6391
Files:
test/dynamic_cast14.cpp
test/dynamic_cast3.cpp
test/dynamic_cast5.cpp
test/dynamic_cast_stress.cpp
test/lit.cfg
test/support/timer.hpp
test/test_demangle.cpp
Index: test/dynamic_cast14.cpp
===================================================================
--- test/dynamic_cast14.cpp
+++ test/dynamic_cast14.cpp
@@ -8,6 +8,7 @@
//===----------------------------------------------------------------------===//
#include <cassert>
+#include "support/timer.hpp"
namespace t1
{
@@ -2172,18 +2173,10 @@
} // t3
-#include <chrono>
-#include <iostream>
-
int main()
{
- typedef std::chrono::high_resolution_clock Clock;
- typedef Clock::time_point time_point;
- typedef std::chrono::duration<double, std::micro> NS;
- time_point t0 = Clock::now();
+ timer t;
t1::test();
t2::test();
t3::test();
- time_point t1 = Clock::now();
- std::cout << NS(t1-t0).count() << " microseconds\n";
}
Index: test/dynamic_cast3.cpp
===================================================================
--- test/dynamic_cast3.cpp
+++ test/dynamic_cast3.cpp
@@ -8,6 +8,7 @@
//===----------------------------------------------------------------------===//
#include <cassert>
+#include "support/timer.hpp"
/*
@@ -2406,15 +2407,9 @@
} // t41
-#include <chrono>
-#include <iostream>
-
int main()
{
- typedef std::chrono::high_resolution_clock Clock;
- typedef Clock::time_point time_point;
- typedef std::chrono::duration<double, std::micro> NS;
- time_point t0 = Clock::now();
+ timer t;
t1::test();
t2::test();
t3::test();
@@ -2456,6 +2451,4 @@
t39::test();
t40::test();
t41::test();
- time_point t1 = Clock::now();
- std::cout << NS(t1-t0).count() << " microseconds\n";
}
Index: test/dynamic_cast5.cpp
===================================================================
--- test/dynamic_cast5.cpp
+++ test/dynamic_cast5.cpp
@@ -8,6 +8,7 @@
//===----------------------------------------------------------------------===//
#include <cassert>
+#include "support/timer.hpp"
namespace t1
{
@@ -1298,15 +1299,10 @@
} // t9
-#include <chrono>
-#include <iostream>
int main()
{
- typedef std::chrono::high_resolution_clock Clock;
- typedef Clock::time_point time_point;
- typedef std::chrono::duration<double, std::micro> NS;
- time_point t0 = Clock::now();
+ timer t;
t1::test();
t2::test();
t3::test();
@@ -1316,6 +1312,4 @@
t7::test();
t8::test();
t9::test();
- time_point t1 = Clock::now();
- std::cout << NS(t1-t0).count() << " microseconds\n";
}
Index: test/dynamic_cast_stress.cpp
===================================================================
--- test/dynamic_cast_stress.cpp
+++ test/dynamic_cast_stress.cpp
@@ -9,8 +9,7 @@
#include <cassert>
#include <tuple>
-#include <chrono>
-#include <iostream>
+#include "support/timer.hpp"
template <std::size_t Indx, std::size_t Depth>
struct C
@@ -50,17 +49,16 @@
void test()
{
- typedef std::chrono::high_resolution_clock Clock;
- typedef std::chrono::duration<double, std::micro> US;
const std::size_t Width = 10;
const std::size_t Depth = 5;
A<Width, Depth> a;
typedef B<Width/2, Depth> Destination;
// typedef A<Width, Depth> Destination;
- auto t0 = Clock::now();
- Destination* b = dynamic_cast<Destination*>((C<Width/2, 0>*)&a);
- auto t1 = Clock::now();
- std::cout << US(t1-t0).count() << " microseconds\n";
+ Destination *b = nullptr;
+ {
+ timer t;
+ b = dynamic_cast<Destination*>((C<Width/2, 0>*)&a);
+ }
assert(b != 0);
}
Index: test/lit.cfg
===================================================================
--- test/lit.cfg
+++ test/lit.cfg
@@ -237,6 +237,10 @@
# Configure extra compiler flags.
+# Always disable timed test when using LIT since the output gets lost and since
+# using the timer requires <chrono> as a dependancy.
+compile_flags += ['-DLIBCXXABI_NO_TIMER']
+
san = lit_config.params.get('llvm_use_sanitizer', None)
if san is None:
san = getattr(config, 'llvm_use_sanitizer', None)
Index: test/support/timer.hpp
===================================================================
--- /dev/null
+++ test/support/timer.hpp
@@ -0,0 +1,46 @@
+#ifndef TIMER_HPP
+#define TIMER_HPP
+
+// Define LIBCXXABI_NO_TIMER to disable testing with a timer.
+#ifndef LIBCXXABI_NO_TIMER
+
+#include <chrono>
+#include <iostream>
+
+class timer
+{
+ typedef std::chrono::high_resolution_clock Clock;
+ typedef Clock::time_point TimePoint;
+ typedef std::chrono::microseconds MicroSeconds;
+public:
+ timer() : m_start(Clock::now()) {}
+
+ timer(timer const &) = delete;
+ timer & operator=(timer const &) = delete;
+
+ ~timer()
+ {
+ using std::chrono::duration_cast;
+ TimePoint end = Clock::now();
+ MicroSeconds us = duration_cast<MicroSeconds>(end - m_start);
+ std::cout << us.count() << " microseconds\n";
+ }
+
+private:
+ TimePoint m_start;
+};
+
+#else /* LIBCXXABI_NO_TIMER */
+
+class timer
+{
+public:
+ timer() {}
+ timer(timer const &) = delete;
+ timer & operator=(timer const &) = delete;
+ ~timer() {}
+};
+
+#endif /* LIBCXXABI_TIME_TESTS */
+
+#endif /* TIMER_HPP */
\ No newline at end of file
Index: test/test_demangle.cpp
===================================================================
--- test/test_demangle.cpp
+++ test/test_demangle.cpp
@@ -12,7 +12,7 @@
#include <cstdlib>
#include <cxxabi.h>
#include <cassert>
-#include <chrono>
+#include "support/timer.hpp"
// Is long double fp80? (Only x87 extended double has 64-bit mantissa)
#define LDBL_FP80 (__LDBL_MANT_DIG__ == 64)
@@ -29664,14 +29664,12 @@
int main()
{
- typedef std::chrono::high_resolution_clock Clock;
- typedef std::chrono::duration<double> sec;
- Clock::time_point t0 = Clock::now();
- test();
- test2();
- Clock::time_point t1 = Clock::now();
- std::cout << sec(t1-t0).count() << " seconds for test\n";
- std::cout << N / sec(t1-t0).count() / 1000000. << " million symbols per second\n";
+ std::cout << "Testing " << N << " symbols." << std::endl;
+ {
+ timer t;
+ test();
+ test2();
+ }
#if 0
std::string input;
while (std::cin)
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits