MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / latencyDistMode

Function latencyDistMode

src/redis-cli.c:6064–6140  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6062}
6063
6064static void latencyDistMode(void) {
6065 redisReply *reply;
6066 long long start, latency, count = 0;
6067 long long history_interval =
6068 config.interval ? config.interval/1000 :
6069 LATENCY_DIST_DEFAULT_INTERVAL;
6070 long long history_start = ustime();
6071 int j, outputs = 0;
6072
6073 struct distsamples samples[] = {
6074 /* We use a mostly logarithmic scale, with certain linear intervals
6075 * which are more interesting than others, like 1-10 milliseconds
6076 * range. */
6077 {10,0,'.'}, /* 0.01 ms */
6078 {125,0,'-'}, /* 0.125 ms */
6079 {250,0,'*'}, /* 0.25 ms */
6080 {500,0,'#'}, /* 0.5 ms */
6081 {1000,0,'1'}, /* 1 ms */
6082 {2000,0,'2'}, /* 2 ms */
6083 {3000,0,'3'}, /* 3 ms */
6084 {4000,0,'4'}, /* 4 ms */
6085 {5000,0,'5'}, /* 5 ms */
6086 {6000,0,'6'}, /* 6 ms */
6087 {7000,0,'7'}, /* 7 ms */
6088 {8000,0,'8'}, /* 8 ms */
6089 {9000,0,'9'}, /* 9 ms */
6090 {10000,0,'A'}, /* 10 ms */
6091 {20000,0,'B'}, /* 20 ms */
6092 {30000,0,'C'}, /* 30 ms */
6093 {40000,0,'D'}, /* 40 ms */
6094 {50000,0,'E'}, /* 50 ms */
6095 {100000,0,'F'}, /* 0.1 s */
6096 {200000,0,'G'}, /* 0.2 s */
6097 {300000,0,'H'}, /* 0.3 s */
6098 {400000,0,'I'}, /* 0.4 s */
6099 {500000,0,'J'}, /* 0.5 s */
6100 {1000000,0,'K'}, /* 1 s */
6101 {2000000,0,'L'}, /* 2 s */
6102 {4000000,0,'M'}, /* 4 s */
6103 {8000000,0,'N'}, /* 8 s */
6104 {16000000,0,'O'}, /* 16 s */
6105 {30000000,0,'P'}, /* 30 s */
6106 {60000000,0,'Q'}, /* 1 minute */
6107 {0,0,'?'}, /* > 1 minute */
6108 };
6109
6110 if (!context) exit(1);
6111 while(1) {
6112 start = ustime();
6113 reply = reconnectingRedisCommand(context,"PING");
6114 if (reply == NULL) {
6115 fprintf(stderr,"\nI/O error\n");
6116 exit(1);
6117 }
6118 latency = ustime()-start;
6119 freeReplyObject(reply);
6120 count++;
6121

Callers 1

mainFunction · 0.85

Calls 5

reconnectingRedisCommandFunction · 0.85
freeReplyObjectFunction · 0.85
showLatencyDistLegendFunction · 0.85
showLatencyDistSamplesFunction · 0.85
ustimeFunction · 0.70

Tested by

no test coverage detected