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

Function getServerCpuTime

src/keydb-diagnostic-tool.cpp:810–829  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

808}
809
810double getServerCpuTime(redisContext *ctx) {
811 redisReply *reply = (redisReply*)redisCommand(ctx, "INFO CPU");
812 if (reply->type != REDIS_REPLY_STRING) {
813 freeReplyObject(reply);
814 printf("Error executing INFO command. Exiting.\n");
815 return -1;
816 }
817
818 double used_cpu_user, used_cpu_sys;
819 if (extractPropertyFromInfo(reply->str, "used_cpu_user", used_cpu_user)) {
820 printf("Error reading user CPU usage from INFO command. Exiting.\n");
821 return -1;
822 }
823 if (extractPropertyFromInfo(reply->str, "used_cpu_sys", used_cpu_sys)) {
824 printf("Error reading system CPU usage from INFO command. Exiting.\n");
825 return -1;
826 }
827 freeReplyObject(reply);
828 return used_cpu_user + used_cpu_sys;
829}
830
831double getMean(std::deque<double> *q) {
832 double sum = 0;

Callers 1

mainFunction · 0.85

Calls 3

freeReplyObjectFunction · 0.85
extractPropertyFromInfoFunction · 0.85
redisCommandClass · 0.70

Tested by

no test coverage detected