summaryrefslogtreecommitdiff
path: root/test/support
diff options
context:
space:
mode:
authorEric Fiselier <eric@efcs.ca>2014-11-24 22:38:57 +0000
committerEric Fiselier <eric@efcs.ca>2014-11-24 22:38:57 +0000
commit30ad829825ee45cab4bc132e5145b2cb7eef4c45 (patch)
treec35bbfcf863c174f951a48e2a4bf242b071a1459 /test/support
parent1b4ddb114e91d196cf3a652124e70560edf3816c (diff)
[libcxxabi] Refactor test timing logic and disable by default.
Summary: When using LIT the timing output is entirely unused but introduces a dependency on `<chrono>`. When libc++ is built without a montonic clock this causes some of the tests to fail. This patch factors out all of the timing logic into `support/timer.hpp` and disables it by default. To enable the timing you must define `LIBCXXABI_TIME_TESTS`. Reviewers: mclow.lists, danalbert, jroelofs Reviewed By: jroelofs Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D6391 git-svn-id: https://llvm.org/svn/llvm-project/libcxxabi/trunk@222701 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/support')
-rw-r--r--test/support/timer.hpp46
1 files changed, 46 insertions, 0 deletions
diff --git a/test/support/timer.hpp b/test/support/timer.hpp
new file mode 100644
index 0000000..a3d51d7
--- /dev/null
+++ b/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