| 6972 | } |
| 6973 | |
| 6974 | static void latencyDistMode(void) { |
| 6975 | redisReply *reply; |
| 6976 | long long start, latency, count = 0; |
| 6977 | long long history_interval = |
| 6978 | config.interval ? config.interval/1000 : |
| 6979 | LATENCY_DIST_DEFAULT_INTERVAL; |
| 6980 | long long history_start = ustime(); |
| 6981 | int j, outputs = 0; |
| 6982 | |
| 6983 | struct distsamples samples[] = { |
| 6984 | /* We use a mostly logarithmic scale, with certain linear intervals |
| 6985 | * which are more interesting than others, like 1-10 milliseconds |
| 6986 | * range. */ |
| 6987 | {10,0,'.'}, /* 0.01 ms */ |
| 6988 | {125,0,'-'}, /* 0.125 ms */ |
| 6989 | {250,0,'*'}, /* 0.25 ms */ |
| 6990 | {500,0,'#'}, /* 0.5 ms */ |
| 6991 | {1000,0,'1'}, /* 1 ms */ |
| 6992 | {2000,0,'2'}, /* 2 ms */ |
| 6993 | {3000,0,'3'}, /* 3 ms */ |
| 6994 | {4000,0,'4'}, /* 4 ms */ |
| 6995 | {5000,0,'5'}, /* 5 ms */ |
| 6996 | {6000,0,'6'}, /* 6 ms */ |
| 6997 | {7000,0,'7'}, /* 7 ms */ |
| 6998 | {8000,0,'8'}, /* 8 ms */ |
| 6999 | {9000,0,'9'}, /* 9 ms */ |
| 7000 | {10000,0,'A'}, /* 10 ms */ |
| 7001 | {20000,0,'B'}, /* 20 ms */ |
| 7002 | {30000,0,'C'}, /* 30 ms */ |
| 7003 | {40000,0,'D'}, /* 40 ms */ |
| 7004 | {50000,0,'E'}, /* 50 ms */ |
| 7005 | {100000,0,'F'}, /* 0.1 s */ |
| 7006 | {200000,0,'G'}, /* 0.2 s */ |
| 7007 | {300000,0,'H'}, /* 0.3 s */ |
| 7008 | {400000,0,'I'}, /* 0.4 s */ |
| 7009 | {500000,0,'J'}, /* 0.5 s */ |
| 7010 | {1000000,0,'K'}, /* 1 s */ |
| 7011 | {2000000,0,'L'}, /* 2 s */ |
| 7012 | {4000000,0,'M'}, /* 4 s */ |
| 7013 | {8000000,0,'N'}, /* 8 s */ |
| 7014 | {16000000,0,'O'}, /* 16 s */ |
| 7015 | {30000000,0,'P'}, /* 30 s */ |
| 7016 | {60000000,0,'Q'}, /* 1 minute */ |
| 7017 | {0,0,'?'}, /* > 1 minute */ |
| 7018 | }; |
| 7019 | |
| 7020 | if (!context) exit(1); |
| 7021 | while(1) { |
| 7022 | start = ustime(); |
| 7023 | reply = reconnectingRedisCommand(context,"PING"); |
| 7024 | if (reply == NULL) { |
| 7025 | fprintf(stderr,"\nI/O error\n"); |
| 7026 | exit(1); |
| 7027 | } |
| 7028 | latency = ustime()-start; |
| 7029 | freeReplyObject(reply); |
| 7030 | count++; |
| 7031 |
no test coverage detected