Invoked per batch in the test loop. Holding a lock looks not scalable. Tested with 1 ~ 8 threads, no noticeable overhead is observed. A better approach may be calculate per-thread quantiles and merge.
| 109 | // Tested with 1 ~ 8 threads, no noticeable overhead is observed. |
| 110 | // A better approach may be calculate per-thread quantiles and merge. |
| 111 | void AddLatency(uint64_t elapsed_nanos) { |
| 112 | std::lock_guard<std::mutex> lock(this->mutex); |
| 113 | latencies.Add(static_cast<double>(elapsed_nanos)); |
| 114 | } |
| 115 | |
| 116 | // ns -> us |
| 117 | uint64_t max_latency() const { return latencies.Max() / 1000; } |
no test coverage detected