feat: chrono update duration=1ms
Some checks failed
linux-mips-gcc / linux-gcc-mipsel (Debug) (push) Waiting to run
linux-mips-gcc / linux-gcc-mipsel (Release) (push) Waiting to run
linux-mips64-gcc / linux-gcc-mips64el (Debug) (push) Waiting to run
linux-mips64-gcc / linux-gcc-mips64el (Release) (push) Waiting to run
linux-riscv64-gcc / linux-gcc-riscv64 (Debug) (push) Waiting to run
linux-riscv64-gcc / linux-gcc-riscv64 (Release) (push) Waiting to run
linux-x64-clang / linux-clang (Debug) (push) Waiting to run
linux-x64-clang / linux-clang (Release) (push) Waiting to run
linux-x64-gcc / linux-gcc (Debug) (push) Waiting to run
linux-x64-gcc / linux-gcc (Release) (push) Waiting to run
linux-x86-gcc / linux-gcc (Debug) (push) Waiting to run
linux-x86-gcc / linux-gcc (Release) (push) Waiting to run
android / build (push) Failing after 24s
linux-aarch64-cpu-gcc / linux-gcc-aarch64 (Debug) (push) Failing after 1m16s
linux-aarch64-cpu-gcc / linux-gcc-aarch64 (Release) (push) Failing after 1m18s
linux-arm-gcc / linux-gcc-arm (Debug) (push) Failing after 1m26s
linux-arm-gcc / linux-gcc-arm (Release) (push) Failing after 10m33s
linux-arm-gcc / linux-gcc-armhf (Debug) (push) Failing after 16m32s
linux-arm-gcc / linux-gcc-armhf (Release) (push) Has been cancelled
Some checks failed
linux-mips-gcc / linux-gcc-mipsel (Debug) (push) Waiting to run
linux-mips-gcc / linux-gcc-mipsel (Release) (push) Waiting to run
linux-mips64-gcc / linux-gcc-mips64el (Debug) (push) Waiting to run
linux-mips64-gcc / linux-gcc-mips64el (Release) (push) Waiting to run
linux-riscv64-gcc / linux-gcc-riscv64 (Debug) (push) Waiting to run
linux-riscv64-gcc / linux-gcc-riscv64 (Release) (push) Waiting to run
linux-x64-clang / linux-clang (Debug) (push) Waiting to run
linux-x64-clang / linux-clang (Release) (push) Waiting to run
linux-x64-gcc / linux-gcc (Debug) (push) Waiting to run
linux-x64-gcc / linux-gcc (Release) (push) Waiting to run
linux-x86-gcc / linux-gcc (Debug) (push) Waiting to run
linux-x86-gcc / linux-gcc (Release) (push) Waiting to run
android / build (push) Failing after 24s
linux-aarch64-cpu-gcc / linux-gcc-aarch64 (Debug) (push) Failing after 1m16s
linux-aarch64-cpu-gcc / linux-gcc-aarch64 (Release) (push) Failing after 1m18s
linux-arm-gcc / linux-gcc-arm (Debug) (push) Failing after 1m26s
linux-arm-gcc / linux-gcc-arm (Release) (push) Failing after 10m33s
linux-arm-gcc / linux-gcc-armhf (Debug) (push) Failing after 16m32s
linux-arm-gcc / linux-gcc-armhf (Release) (push) Has been cancelled
This commit is contained in:
parent
88dfe5d323
commit
3c9e2260c8
@ -331,6 +331,7 @@ endfunction(add_test_group)
|
|||||||
add_test_group(${CMAKE_CURRENT_SOURCE_DIR}/tile/net net)
|
add_test_group(${CMAKE_CURRENT_SOURCE_DIR}/tile/net net)
|
||||||
add_test_group(${CMAKE_CURRENT_SOURCE_DIR}/tile/rpc rpc)
|
add_test_group(${CMAKE_CURRENT_SOURCE_DIR}/tile/rpc rpc)
|
||||||
tile_add_custom_test("custom_http_client_test" "tests/http_client_test.cc")
|
tile_add_custom_test("custom_http_client_test" "tests/http_client_test.cc")
|
||||||
|
tile_add_custom_test("tile_cpu_test" "tile/tile_cpu_test.cc")
|
||||||
endif(TILE_BUILD_TESTS)
|
endif(TILE_BUILD_TESTS)
|
||||||
|
|
||||||
if(TILE_BUILD_BENCHMARKS)
|
if(TILE_BUILD_BENCHMARKS)
|
||||||
|
@ -17,7 +17,7 @@ namespace chrono {
|
|||||||
|
|
||||||
class CoarseClockInitializer {
|
class CoarseClockInitializer {
|
||||||
public:
|
public:
|
||||||
static constexpr auto kAccuracy = std::chrono::microseconds(500);
|
static constexpr auto kAccuracy = std::chrono::microseconds(1000);
|
||||||
static CoarseClockInitializer *Instance();
|
static CoarseClockInitializer *Instance();
|
||||||
|
|
||||||
// for `tile::Start()`
|
// for `tile::Start()`
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
namespace tile {
|
namespace tile {
|
||||||
|
|
||||||
static constexpr auto one_ms = std::chrono::milliseconds(1);
|
static constexpr auto one_ms = std::chrono::milliseconds(1);
|
||||||
|
static constexpr auto diff_ms = 10;
|
||||||
static constexpr auto kTestN = 1000;
|
static constexpr auto kTestN = 1000;
|
||||||
|
|
||||||
long
|
long
|
||||||
@ -21,24 +22,24 @@ AvageTime(std::function<long()> f, std::size_t n = kTestN)
|
|||||||
TEST(SystemClock, Compare)
|
TEST(SystemClock, Compare)
|
||||||
{
|
{
|
||||||
auto diff = AvageTime([] { return (ReadSystemClock() - std::chrono::system_clock::now()) / one_ms; });
|
auto diff = AvageTime([] { return (ReadSystemClock() - std::chrono::system_clock::now()) / one_ms; });
|
||||||
ASSERT_NEAR(diff, 0, 5);
|
ASSERT_NEAR(diff, 0, diff_ms);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(SteadyClock, Compare)
|
TEST(SteadyClock, Compare)
|
||||||
{
|
{
|
||||||
auto diff = AvageTime([] { return (ReadSteadyClock() - std::chrono::steady_clock::now()) / one_ms; });
|
auto diff = AvageTime([] { return (ReadSteadyClock() - std::chrono::steady_clock::now()) / one_ms; });
|
||||||
ASSERT_NEAR(diff, 0, 5);
|
ASSERT_NEAR(diff, 0, diff_ms);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(CoarseSystemClock, Compare)
|
TEST(CoarseSystemClock, Compare)
|
||||||
{
|
{
|
||||||
auto diff = AvageTime([] { return (ReadCoarseSystemClock() - std::chrono::system_clock::now()) / one_ms; });
|
auto diff = AvageTime([] { return (ReadCoarseSystemClock() - std::chrono::system_clock::now()) / one_ms; });
|
||||||
ASSERT_NEAR(diff, 0, kTestN);
|
ASSERT_NEAR(diff, 0, kTestN * diff_ms);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(CoarseSteadyClock, Compare)
|
TEST(CoarseSteadyClock, Compare)
|
||||||
{
|
{
|
||||||
auto diff = AvageTime([] { return (ReadCoarseSteadyClock() - std::chrono::steady_clock::now()) / one_ms; });
|
auto diff = AvageTime([] { return (ReadCoarseSteadyClock() - std::chrono::steady_clock::now()) / one_ms; });
|
||||||
ASSERT_NEAR(diff, 0, kTestN);
|
ASSERT_NEAR(diff, 0, kTestN * diff_ms);
|
||||||
}
|
}
|
||||||
}// namespace tile
|
}// namespace tile
|
||||||
|
5
tile/tile_cpu_test.cc
Normal file
5
tile/tile_cpu_test.cc
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
#include "tile/tile.h"
|
||||||
|
|
||||||
|
#include "gtest/gtest.h"
|
||||||
|
|
||||||
|
TEST(CPU, Base) { std::this_thread::sleep_for(std::chrono::seconds(30)); }
|
Loading…
Reference in New Issue
Block a user