Compare commits
5 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
4048a07229 | ||
|
90bb082ef9 | ||
|
68c3f526fd | ||
|
c755acfe14 | ||
|
3c9e2260c8 |
@ -20,17 +20,17 @@ set(CMAKE_CXX_EXTENSIONS OFF)
|
||||
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||
|
||||
# add static libgcc and libstdc++ for static linking
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -static-libgcc -static-libstdc++")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libgcc -static-libstdc++")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -static-libgcc")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libgcc")
|
||||
|
||||
option(TILE_BUILD_TESTS "Build tests" OFF)
|
||||
option(TILE_BUILD_BENCHMARKS "Build tests" OFF)
|
||||
option(TILE_BUILD_TESTS "Build tests" ON)
|
||||
option(TILE_BUILD_BENCHMARKS "Build tests" ON)
|
||||
option(TILE_WITH_OPENSSL "Build with openssl" OFF)
|
||||
option(TILE_BUILD_SHARED "Build shared library" ON)
|
||||
|
||||
if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
|
||||
set(TILE_BUILD_TESTS ON)
|
||||
set(TILE_BUILD_BENCHMARKS ON)
|
||||
if(NOT CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
|
||||
set(TILE_BUILD_TESTS OFF)
|
||||
set(TILE_BUILD_BENCHMARKS OFF)
|
||||
endif()
|
||||
|
||||
if(NOT CMAKE_BUILD_TYPE)
|
||||
@ -227,8 +227,10 @@ endif()
|
||||
|
||||
if (TILE_BUILD_SHARED)
|
||||
add_library(tile SHARED ${TILE_SRCS})
|
||||
message(STATUS "Build tile shared library")
|
||||
else()
|
||||
add_library(tile STATIC ${TILE_SRCS})
|
||||
add_library(tile OBJECT ${TILE_SRCS})
|
||||
message(STATUS "Build tile object library")
|
||||
endif()
|
||||
set_target_properties(tile PROPERTIES VERSION ${PROJECT_VERSION}
|
||||
target_precompile_headers(tile PUBLIC inja/inja.h)
|
||||
@ -331,6 +333,7 @@ endfunction(add_test_group)
|
||||
add_test_group(${CMAKE_CURRENT_SOURCE_DIR}/tile/net net)
|
||||
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("tile_cpu_test" "tile/tile_cpu_test.cc")
|
||||
endif(TILE_BUILD_TESTS)
|
||||
|
||||
if(TILE_BUILD_BENCHMARKS)
|
||||
|
@ -17,7 +17,7 @@ namespace chrono {
|
||||
|
||||
class CoarseClockInitializer {
|
||||
public:
|
||||
static constexpr auto kAccuracy = std::chrono::microseconds(500);
|
||||
static constexpr auto kAccuracy = std::chrono::microseconds(1000);
|
||||
static CoarseClockInitializer *Instance();
|
||||
|
||||
// for `tile::Start()`
|
||||
|
@ -4,8 +4,9 @@
|
||||
|
||||
namespace tile {
|
||||
|
||||
static constexpr auto one_ms = std::chrono::milliseconds(1);
|
||||
static constexpr auto kTestN = 1000;
|
||||
static constexpr auto one_ms = std::chrono::milliseconds(1);
|
||||
static constexpr auto diff_ms = 10;
|
||||
static constexpr auto kTestN = 1000;
|
||||
|
||||
long
|
||||
AvageTime(std::function<long()> f, std::size_t n = kTestN)
|
||||
@ -21,24 +22,24 @@ AvageTime(std::function<long()> f, std::size_t n = kTestN)
|
||||
TEST(SystemClock, Compare)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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
|
||||
|
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