MCPcopy Create free account
hub / github.com/baidu/tera / TEST

Function TEST

src/common/test/thread_pool_test.cc:24–43  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

22namespace tera {
23
24TEST(TimerTest, Basic) {
25 struct timespec ts1, ts2, ts3;
26 struct timeval tv;
27
28 clock_gettime(CLOCK_MONOTONIC, &ts1);
29 clock_gettime(CLOCK_MONOTONIC_RAW, &ts3);
30 clock_gettime(CLOCK_REALTIME, &ts2);
31 gettimeofday(&tv, NULL);
32
33 std::cout << "ts1.tv_sec " << ts1.tv_sec << ", ts1.tv_nsec " << ts1.tv_nsec << std::endl;
34 std::cout << "ts2.tv_sec " << ts2.tv_sec << ", ts2.tv_nsec " << ts2.tv_nsec << std::endl;
35 std::cout << "ts3.tv_sec " << ts3.tv_sec << ", ts3.tv_nsec " << ts3.tv_nsec << std::endl;
36 std::cout << "tv.tv_sec " << tv.tv_sec << ", tv.tv_usec " << tv.tv_usec << std::endl;
37
38 int delta = 0;
39 delta = ts2.tv_sec - tv.tv_sec;
40 ASSERT_TRUE(-1 <= delta && delta <= 1);
41 ASSERT_TRUE(ts1.tv_sec < ts2.tv_sec);
42 ASSERT_TRUE(ts1.tv_sec < tv.tv_sec);
43}
44
45TEST(TimerTest, test1) {
46 struct timespec ts1;

Callers

nothing calls this directly

Calls 5

DelayTaskMethod · 0.80
get_microsFunction · 0.50
LockMethod · 0.45
WaitMethod · 0.45
UnlockMethod · 0.45

Tested by

no test coverage detected