//===----------------------------------------------------------------------===//
#include <cassert>
+#include "support/timer.hpp"
namespace t1
{
} // 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";
}
//===----------------------------------------------------------------------===//
#include <cassert>
+#include "support/timer.hpp"
/*
} // 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();
t39::test();
t40::test();
t41::test();
- time_point t1 = Clock::now();
- std::cout << NS(t1-t0).count() << " microseconds\n";
}
//===----------------------------------------------------------------------===//
#include <cassert>
+#include "support/timer.hpp"
namespace t1
{
} // 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();
t7::test();
t8::test();
t9::test();
- time_point t1 = Clock::now();
- std::cout << NS(t1-t0).count() << " microseconds\n";
}
#include <cassert>
#include <tuple>
-#include <chrono>
-#include <iostream>
+#include "support/timer.hpp"
template <std::size_t Indx, std::size_t Depth>
struct C
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);
}
# 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)
--- /dev/null
+#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
//
//===----------------------------------------------------------------------===//
+#include "support/timer.hpp"
#include <iostream>
#include <string>
#include <cstdlib>
#include <cxxabi.h>
#include <cassert>
-#include <chrono>
// Is long double fp80? (Only x87 extended double has 64-bit mantissa)
#define LDBL_FP80 (__LDBL_MANT_DIG__ == 64)
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)