blob: b733869c39b859f678e5ac98802213e45ec19bb1 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include <vespa/vespalib/testkit/testapp.h>
#include <vespa/vespalib/util/clock.h>
using vespalib::Clock;
using fastos::TimeStamp;
class Test : public vespalib::TestApp
{
public:
int Main() override;
};
int
Test::Main()
{
TEST_INIT("clock_test");
Clock clock(0.050);
FastOS_ThreadPool pool(0x10000);
ASSERT_TRUE(pool.NewThread(&clock, NULL) != NULL);
uint64_t start = clock.getTimeNS();
FastOS_Thread::Sleep(5000);
uint64_t stop = clock.getTimeNS();
EXPECT_TRUE(stop > start);
FastOS_Thread::Sleep(6000);
clock.stop();
uint64_t stop2 = clock.getTimeNS();
EXPECT_TRUE(stop2 > stop);
EXPECT_TRUE((stop2 - stop)/TimeStamp::MICRO > 1000);
TEST_DONE();
}
TEST_APPHOOK(Test)
|