| 841 | } |
| 842 | |
| 843 | int main(int argc, const char **argv) { |
| 844 | int i; |
| 845 | |
| 846 | storage_init(NULL, 0); |
| 847 | |
| 848 | srandom(time(NULL)); |
| 849 | signal(SIGHUP, SIG_IGN); |
| 850 | signal(SIGPIPE, SIG_IGN); |
| 851 | |
| 852 | initConfigDefaults(); |
| 853 | |
| 854 | i = parseOptions(argc,argv); |
| 855 | argc -= i; |
| 856 | argv += i; |
| 857 | |
| 858 | config.latency = (long long*)zmalloc(sizeof(long long)*config.requests, MALLOC_LOCAL); |
| 859 | |
| 860 | if (config.max_threads > 0) { |
| 861 | int err = 0; |
| 862 | err |= pthread_mutex_init(&(config.requests_issued_mutex), NULL); |
| 863 | err |= pthread_mutex_init(&(config.requests_finished_mutex), NULL); |
| 864 | err |= pthread_mutex_init(&(config.liveclients_mutex), NULL); |
| 865 | err |= pthread_mutex_init(&(config.is_fetching_slots_mutex), NULL); |
| 866 | err |= pthread_mutex_init(&(config.is_updating_slots_mutex), NULL); |
| 867 | err |= pthread_mutex_init(&(config.updating_slots_mutex), NULL); |
| 868 | err |= pthread_mutex_init(&(config.slots_last_update_mutex), NULL); |
| 869 | if (err != 0) |
| 870 | { |
| 871 | perror("Failed to initialize mutex"); |
| 872 | exit(EXIT_FAILURE); |
| 873 | } |
| 874 | } |
| 875 | |
| 876 | const char *set_value = "abcdefghijklmnopqrstuvwxyz"; |
| 877 | int self_threads = 0; |
| 878 | char command[63]; |
| 879 | |
| 880 | initBenchmarkThreads(); |
| 881 | redisContext *ctx = getRedisContext(config.hostip, config.hostport, config.hostsocket); |
| 882 | double server_cpu_time, last_server_cpu_time = getServerCpuTime(ctx); |
| 883 | struct rusage self_ru; |
| 884 | double self_cpu_time, last_self_cpu_time = getSelfCpuTime(&self_ru); |
| 885 | double server_cpu_load, last_server_cpu_load = 0, self_cpu_load, server_cpu_gain; |
| 886 | std::deque<double> load_gain_history = {}; |
| 887 | double current_gain_avg, peak_gain_avg = 0; |
| 888 | |
| 889 | redisReply *reply = (redisReply*)redisCommand(ctx, "INFO CPU"); |
| 890 | if (reply->type != REDIS_REPLY_STRING) { |
| 891 | freeReplyObject(reply); |
| 892 | printf("Error executing INFO command. Exiting.\r\n"); |
| 893 | return 1; |
| 894 | } |
| 895 | unsigned int server_threads; |
| 896 | if (extractPropertyFromInfo(reply->str, "server_threads", server_threads)) { |
| 897 | printf("Error reading server threads from INFO command. Exiting.\r\n"); |
| 898 | return 1; |
| 899 | } |
| 900 | freeReplyObject(reply); |
nothing calls this directly
no test coverage detected