| 808 | } |
| 809 | |
| 810 | double 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 | |
| 831 | double getMean(std::deque<double> *q) { |
| 832 | double sum = 0; |
no test coverage detected