Measuring latencies at the exchange
First, we will add instrumentation to the components on the electronic trading exchange side – the market data publisher, the matching engine, and the order server. Our approach to measuring performance will comprise two forms; let us understand those first before we look at the code.
Understanding how to measure internally
The first approach is to measure the latency of internal components – for example, how long does a call to the Exchange::MatchingEngine::processClientRequest() method take or how long does a call to the Exchange::MEOrderBook::add() method take? For these cases, we will use a pair of START_MEASURE() and END_MEASURE() macros, which, in turn, use the rdtsc() method to measure the performance of each such call. There is nothing here that prevents us from using the TTT_MEASURE() macro in place of rdtsc() or as a supplement. But we will use rdtsc() for these, for the sake of providing examples of how to use the two...