Memtiter-benchmark源码解析4--clients.cpp, run_stats.cpp, shard_connections联合统计latency

Posted 银灯玉箫

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Memtiter-benchmark源码解析4--clients.cpp, run_stats.cpp, shard_connections联合统计latency相关的知识,希望对你有一定的参考价值。

run_stats_types.h

run_stats_types 包含了几个统计latency重要的类

one_sec_cmd_stats

shard_connection.cpp send a set command

class run_stats

run_stats.h

Important members:

one_second_stats m_cur_stats; // current second stats (appended to m_stats and reset every second)

totals m_totals; // the final statistics of latency

instantaneous command stats (used in the per second latencies)

inst_m_get_latency_histogram;

How to record the latency for each request?

Each client has a proteced member call m_stats which is an instance of class run_stats.

In the handle_response function at Client.cpp, the client calls the update_set_op funcion of m_stats to collect the latency for a request (Line 391).

接博客末尾 Memtiter-benchmark源码解析2–shard_connection
At client.cpp

At Line 393, we can see that the latency of a request is equal to the difference between a request’s sent time and its reponse’s recieved time.

client invokes the update_set_op funcion of a run_stats.

Then a run_stats calls the corresponding functions to record the latency.

Finally, we call the global hdr_record_value funcion in hdr_historgram.h to record the latency for each request at Line 190.

以上是关于Memtiter-benchmark源码解析4--clients.cpp, run_stats.cpp, shard_connections联合统计latency的主要内容,如果未能解决你的问题,请参考以下文章

Memtiter-benchmark源码解析3--protocol

Memtiter-benchmark源码解析1client类功能解析

Memtiter-benchmark源码解析1client类功能解析

Memtiter-benchmark源码解析2--shared_connection

Memtiter-benchmark源码解析2--shared_connection

IdentityServer4源码解析_4_令牌发放接口