| 992 | } |
| 993 | |
| 994 | static void benchmark(const char *title, const char *cmd, int len) { |
| 995 | client c; |
| 996 | |
| 997 | config.title = title; |
| 998 | config.requests_issued = 0; |
| 999 | config.requests_finished = 0; |
| 1000 | config.previous_requests_finished = 0; |
| 1001 | config.last_printed_bytes = 0; |
| 1002 | hdr_init( |
| 1003 | CONFIG_LATENCY_HISTOGRAM_MIN_VALUE, // Minimum value |
| 1004 | CONFIG_LATENCY_HISTOGRAM_MAX_VALUE, // Maximum value |
| 1005 | config.precision, // Number of significant figures |
| 1006 | &config.latency_histogram); // Pointer to initialise |
| 1007 | hdr_init( |
| 1008 | CONFIG_LATENCY_HISTOGRAM_MIN_VALUE, // Minimum value |
| 1009 | CONFIG_LATENCY_HISTOGRAM_INSTANT_MAX_VALUE, // Maximum value |
| 1010 | config.precision, // Number of significant figures |
| 1011 | &config.current_sec_latency_histogram); // Pointer to initialise |
| 1012 | |
| 1013 | if (config.num_threads) initBenchmarkThreads(); |
| 1014 | |
| 1015 | int thread_id = config.num_threads > 0 ? 0 : -1; |
| 1016 | c = createClient(cmd,len,NULL,thread_id); |
| 1017 | createMissingClients(c); |
| 1018 | |
| 1019 | config.start = mstime(); |
| 1020 | if (!config.num_threads) { |
| 1021 | aeThreadOnline(); |
| 1022 | aeMain(config.el); |
| 1023 | aeThreadOffline(); |
| 1024 | } |
| 1025 | else startBenchmarkThreads(); |
| 1026 | config.totlatency = mstime()-config.start; |
| 1027 | |
| 1028 | showLatencyReport(); |
| 1029 | freeAllClients(); |
| 1030 | if (config.threads) freeBenchmarkThreads(); |
| 1031 | if (config.current_sec_latency_histogram) hdr_close(config.current_sec_latency_histogram); |
| 1032 | if (config.latency_histogram) hdr_close(config.latency_histogram); |
| 1033 | |
| 1034 | } |
| 1035 | |
| 1036 | /* Thread functions. */ |
| 1037 |
no test coverage detected