feat update chrono
Some checks failed
linux-aarch64-cpu-gcc / linux-gcc-aarch64 (Debug) (push) Failing after 3m26s
linux-arm-gcc / linux-gcc-arm (Debug) (push) Failing after 3m57s
linux-aarch64-cpu-gcc / linux-gcc-aarch64 (Release) (push) Successful in 5m39s
linux-arm-gcc / linux-gcc-arm (Release) (push) Successful in 5m45s
linux-arm-gcc / linux-gcc-armhf (Debug) (push) Failing after 2m40s
linux-mips-gcc / linux-gcc-mipsel (Debug) (push) Failing after 3m24s
linux-arm-gcc / linux-gcc-armhf (Release) (push) Successful in 5m9s
linux-mips64-gcc / linux-gcc-mips64el (Debug) (push) Failing after 3m27s
linux-mips-gcc / linux-gcc-mipsel (Release) (push) Successful in 4m59s
linux-riscv64-gcc / linux-gcc-riscv64 (Debug) (push) Failing after 2m51s
linux-x64-gcc / linux-gcc (Debug) (push) Failing after 3m12s
linux-mips64-gcc / linux-gcc-mips64el (Release) (push) Successful in 5m11s
linux-riscv64-gcc / linux-gcc-riscv64 (Release) (push) Successful in 5m8s
linux-x86-gcc / linux-gcc (Debug) (push) Failing after 55s
linux-x86-gcc / linux-gcc (Release) (push) Failing after 52s
linux-x64-gcc / linux-gcc (Release) (push) Successful in 4m24s
Some checks failed
linux-aarch64-cpu-gcc / linux-gcc-aarch64 (Debug) (push) Failing after 3m26s
linux-arm-gcc / linux-gcc-arm (Debug) (push) Failing after 3m57s
linux-aarch64-cpu-gcc / linux-gcc-aarch64 (Release) (push) Successful in 5m39s
linux-arm-gcc / linux-gcc-arm (Release) (push) Successful in 5m45s
linux-arm-gcc / linux-gcc-armhf (Debug) (push) Failing after 2m40s
linux-mips-gcc / linux-gcc-mipsel (Debug) (push) Failing after 3m24s
linux-arm-gcc / linux-gcc-armhf (Release) (push) Successful in 5m9s
linux-mips64-gcc / linux-gcc-mips64el (Debug) (push) Failing after 3m27s
linux-mips-gcc / linux-gcc-mipsel (Release) (push) Successful in 4m59s
linux-riscv64-gcc / linux-gcc-riscv64 (Debug) (push) Failing after 2m51s
linux-x64-gcc / linux-gcc (Debug) (push) Failing after 3m12s
linux-mips64-gcc / linux-gcc-mips64el (Release) (push) Successful in 5m11s
linux-riscv64-gcc / linux-gcc-riscv64 (Release) (push) Successful in 5m8s
linux-x86-gcc / linux-gcc (Debug) (push) Failing after 55s
linux-x86-gcc / linux-gcc (Release) (push) Failing after 52s
linux-x64-gcc / linux-gcc (Release) (push) Successful in 4m24s
This commit is contained in:
parent
f9c0e90b06
commit
7306461b2f
@ -90,7 +90,8 @@ void CoarseClockInitializer::Start() {
|
||||
while (running_.load(std::memory_order_relaxed)) {
|
||||
// std::this_thread::sleep_for(std::chrono::nanoseconds(500));
|
||||
UpdateCoarseTimestamps();
|
||||
Sleep(accuracy_as_ns / 2);
|
||||
// Sleep(accuracy_as_ns / 2);
|
||||
std::this_thread::sleep_for(kAccuracy / 2);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ namespace chrono {
|
||||
|
||||
class CoarseClockInitializer {
|
||||
public:
|
||||
static constexpr auto kAccuracy = std::chrono::microseconds(100);
|
||||
static constexpr auto kAccuracy = std::chrono::microseconds(500);
|
||||
static CoarseClockInitializer *Instance();
|
||||
|
||||
// for `tile::Start()`
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
namespace tile {
|
||||
|
||||
static constexpr auto one = detail::chrono::CoarseClockInitializer::kAccuracy;
|
||||
static constexpr auto one_ms = std::chrono::milliseconds(1);
|
||||
|
||||
long AvageTime(std::function<long()> f, std::size_t n = 100) {
|
||||
long double total = 0;
|
||||
@ -17,28 +17,30 @@ long AvageTime(std::function<long()> f, std::size_t n = 100) {
|
||||
|
||||
TEST(SystemClock, Compare) {
|
||||
auto diff = AvageTime([] {
|
||||
return (ReadSystemClock() - std::chrono::system_clock::now()) / one;
|
||||
return (ReadSystemClock() - std::chrono::system_clock::now()) / one_ms;
|
||||
});
|
||||
ASSERT_NEAR(diff, 0, 5);
|
||||
}
|
||||
|
||||
TEST(SteadyClock, Compare) {
|
||||
auto diff = AvageTime([] {
|
||||
return (ReadSteadyClock() - std::chrono::steady_clock::now()) / one;
|
||||
return (ReadSteadyClock() - std::chrono::steady_clock::now()) / one_ms;
|
||||
});
|
||||
ASSERT_NEAR(diff, 0, 5);
|
||||
}
|
||||
|
||||
TEST(CoarseSystemClock, Compare) {
|
||||
auto diff = AvageTime([] {
|
||||
return (ReadCoarseSystemClock() - std::chrono::system_clock::now()) / one;
|
||||
return (ReadCoarseSystemClock() - std::chrono::system_clock::now()) /
|
||||
one_ms;
|
||||
});
|
||||
ASSERT_NEAR(diff, 0, 50);
|
||||
}
|
||||
|
||||
TEST(CoarseSteadyClock, Compare) {
|
||||
auto diff = AvageTime([] {
|
||||
return (ReadCoarseSteadyClock() - std::chrono::steady_clock::now()) / one;
|
||||
return (ReadCoarseSteadyClock() - std::chrono::steady_clock::now()) /
|
||||
one_ms;
|
||||
});
|
||||
ASSERT_NEAR(diff, 0, 50);
|
||||
}
|
||||
|
@ -61,6 +61,7 @@ static void BusySleep(std::chrono::duration<Rep, Period> dur) {
|
||||
namespace object_pool {
|
||||
|
||||
TEST(ThreadLocalPool, All) {
|
||||
auto start = ReadCoarseSteadyClock();
|
||||
// create 1000 unref objects;
|
||||
ASSERT_EQ(alive, 0);
|
||||
{
|
||||
@ -76,13 +77,17 @@ TEST(ThreadLocalPool, All) {
|
||||
BusySleep(std::chrono::milliseconds(10));
|
||||
Get<C>().Reset(); // Trigger wash out if possible.
|
||||
}
|
||||
if ((ReadCoarseSteadyClock() - start) < PoolTraits<C>::kMaxIdle) {
|
||||
ASSERT_EQ(PoolTraits<C>::kHighWaterMark + PoolTraits<C>::kLowWaterMark,
|
||||
alive); // High-water mark.
|
||||
}
|
||||
|
||||
// Max idle not reached. No effect.
|
||||
Get<C>().Reset();
|
||||
if ((ReadCoarseSteadyClock() - start) < PoolTraits<C>::kMaxIdle) {
|
||||
ASSERT_EQ(PoolTraits<C>::kHighWaterMark + PoolTraits<C>::kLowWaterMark,
|
||||
alive);
|
||||
}
|
||||
|
||||
BusySleep(std::chrono::milliseconds(5000));
|
||||
// std::this_thread::sleep_for(std::chrono::milliseconds(5000));
|
||||
|
Loading…
x
Reference in New Issue
Block a user