18 #include <glog/logging.h> 26 using std::chrono::duration_cast;
27 using std::chrono::milliseconds;
28 using std::chrono::nanoseconds;
29 using std::chrono::steady_clock;
36 static inline void PrintTo(nanoseconds ns, ::std::ostream* os) {
37 *os << ns.count() <<
"ns";
43 void runThread(nanoseconds duration, nanoseconds* timeWaiting) {
53 VLOG(1) <<
"thread " << start.
getTid() <<
": elapsed " 54 << duration_cast<milliseconds>(
57 <<
"ms, time waiting: " 58 << duration_cast<milliseconds>(*timeWaiting).count() <<
"ms";
71 auto numThreads = sysconf(_SC_NPROCESSORS_CONF) * 2;
73 std::vector<std::thread>
threads;
74 std::vector<nanoseconds> timeWaiting;
75 timeWaiting.resize(numThreads, 0ns);
78 for (
int n = 0; n < numThreads; ++n) {
79 threads.emplace_back(runThread, 1
s, &timeWaiting[n]);
82 for (
auto& thread : threads) {
89 for (
int n = 0; n < numThreads; ++n) {
#define TEST(test_case_name, test_name)
std::chrono::nanoseconds getTimeWaiting() const
std::chrono::steady_clock::time_point now()
static void PrintTo(nanoseconds ns,::std::ostream *os)
#define EXPECT_GE(val1, val2)
std::vector< std::thread::id > threads
auto end(TestAdlIterable &instance)
std::chrono::steady_clock::time_point getTimeStart() const
TimeUtilGeneric<> TimeUtil
#define EXPECT_LT(val1, val2)
StatsClock::time_point TimePoint