![]() |
Xlight API用户手册 v1.7.0.12
Xlight极速柜台接口文档
|
行情延迟测量工具 更多...
#include <cstdint>#include <ctime>命名空间 | |
| namespace | x1 |
函数 | |
| uint64_t | x1::xlt_quote_rx_timestamp_ns () |
| 获取 API 内部收到 UDP 包时记录的硬件时间戳 | |
| bool | x1::xlt_quote_has_rx_hw_timestamp () |
| 当前回调对应的UDP包是否拿到了EFVI硬件RX时间戳 | |
| bool | x1::xlt_quote_has_rx_latency_breakdown () |
| uint64_t | x1::xlt_quote_rx_poll_return_ns () |
| uint64_t | x1::xlt_quote_rx_before_notify_ns () |
| uint32_t | x1::xlt_quote_rx_frame_bytes () |
| uint32_t | x1::xlt_quote_rx_poll_batch_size () |
| uint32_t | x1::xlt_quote_rx_poll_event_index () |
| uint64_t | x1::xlt_quote_rx_timestamp_tsc () |
| 获取 API 内部收到 UDP 包时记录的软件 TSC 时间戳 | |
| void | x1::xlt_quote_set_rx_timestamps (uint64_t rx_tsc, uint64_t timestamp_ns, uint64_t poll_return_ns=0, uint64_t before_notify_ns=0, uint32_t frame_bytes=0, uint32_t poll_batch_size=0, uint32_t poll_event_index=0) |
| uint64_t | x1::xlt_quote_rx_latency_ns () |
| 读取当前 UTC 纳秒时间戳 | |
| uint64_t | x1::xlt_quote_rx_latency_tsc () |
| 读取当前 TSC(用于在 on_quote 入口计算延迟) | |
变量 | |
| thread_local uint64_t | x1::g_quote_rx_tsc |
| 内部使用:API 在调用 on_quote 前写入软件收包 TSC。 | |
| thread_local uint64_t | x1::g_quote_rx_timestamp_ns |
| 内部使用:EFVI硬件RX时间戳(UTC ns),未开启或不可用时为0。 | |
| thread_local uint64_t | x1::g_quote_rx_poll_return_ns |
| 内部使用:诊断时间点,ef_eventq_poll 返回后的系统UTC ns。 | |
| thread_local uint64_t | x1::g_quote_rx_before_notify_ns |
| 内部使用:诊断时间点,调用 on_quote 前的系统UTC ns。 | |
| thread_local uint32_t | x1::g_quote_rx_frame_bytes |
| thread_local uint32_t | x1::g_quote_rx_poll_batch_size |
| thread_local uint32_t | x1::g_quote_rx_poll_event_index |
行情延迟测量工具
提供从 ef_vi/socket 收到 UDP 包到 on_quote 回调之间的内部延迟测量能力。
使用方法: 在 on_quote 回调入口处调用 xlt_quote_rx_latency_tsc() 获取当前 TSC, 然后用其与 xlt_quote_rx_timestamp_tsc() 的差值计算延迟(TSC cycles)。
示例: void on_quote(QuoteMCType mc_type, const void* msg_data, uint32_t msg_len) override { uint64_t now_tsc = xlt_quote_rx_latency_tsc(); uint64_t rx_tsc = xlt_quote_rx_timestamp_tsc(); uint64_t latency_cycles = now_tsc - rx_tsc; uint64_t hw_rx_ns = xlt_quote_rx_timestamp_ns(); // 仅开启EFVI硬件时间戳时非0 ... }