On latency, measurement, and optimization in algorithmic trading systems