Adding an instrumentation system to measure system performance
The first task we need to tackle is to add a few utility methods that will serve as the base of our performance measurement system. These are meant to be used to measure the latencies of internal components and subcomponents for processes running on the same server. These are also meant to be used to measure latencies between the different components, which are unlikely to be on the same server in practice, such as the trading exchange and the trading clients, which are on different servers. Note, however, that in this book, we run the trading exchange and the trading clients on the same server for simplicity. Now, let us start by adding these utilities in the next section.
Adding utilities for performance measurement using RDTSC
The first performance measurement utility we add does not directly measure the time itself but, instead, measures how many CPU clock cycles elapse between two spots in our code base. This...