diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index bde24c3..e282377 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -2,7 +2,7 @@ name: Build and Test on: push: - branches: [ "main" ] + branches: [ "main" , "arm"] pull_request: branches: [ "main" ] diff --git a/README.md b/README.md index 0c5e7d7..8205a65 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ cmake .. cmake --build . --config Release ``` ## Results - +- x64 ```bash Map order book Latency (cycles) @@ -34,3 +34,20 @@ Latency (cycles) p99: 3520 p99.9: 5640 ``` + +- ARM +```bash +Map order book +Latency (cycles) + p50: 42 + p90: 84 + p99: 167 + p99.9: 1167 + +Vector order book +Latency (cycles) + p50: 42 + p90: 125 + p99: 375 + p99.9: 625 + ``` \ No newline at end of file diff --git a/include/orderbook/timing.hpp b/include/orderbook/timing.hpp index 5bc965e..4875040 100644 --- a/include/orderbook/timing.hpp +++ b/include/orderbook/timing.hpp @@ -1,21 +1,28 @@ #pragma once #include +#include -#if defined(__x86_64__) || defined(_M_X64) -#ifdef _MSC_VER -#include -static inline uint64_t rdtsc() -{ - return __rdtsc(); +inline uint64_t now_ns() { + return std::chrono::duration_cast( + std::chrono::steady_clock::now().time_since_epoch() + ).count(); } -#else -static inline uint64_t rdtsc() -{ - uint32_t lo, hi; - asm volatile("rdtsc" : "=a"(lo), "=d"(hi)); - return (static_cast(hi) << 32) | lo; -} -#endif -#else -#error "rdtsc only supported on x86_64" -#endif + +// #if defined(__x86_64__) || defined(_M_X64) +// #ifdef _MSC_VER +// #include +// static inline uint64_t rdtsc() +// { +// return __rdtsc(); +// } +// #else +// static inline uint64_t rdtsc() +// { +// uint32_t lo, hi; +// asm volatile("rdtsc" : "=a"(lo), "=d"(hi)); +// return (static_cast(hi) << 32) | lo; +// } +// #endif +// #else +// #error "rdtsc only supported on x86_64" +// #endif diff --git a/src/dispatcher.cpp b/src/dispatcher.cpp index 3552751..27dc483 100644 --- a/src/dispatcher.cpp +++ b/src/dispatcher.cpp @@ -8,7 +8,7 @@ void Dispatcher::run( { for (const auto &msg : feed.messages()) { - uint64_t start = rdtsc(); + uint64_t start = now_ns(); switch (msg.type) { @@ -31,7 +31,7 @@ void Dispatcher::run( break; } - uint64_t end = rdtsc(); + uint64_t end = now_ns(); recorder.record(end - start); } }