| 1641 | } |
| 1642 | |
| 1643 | int showThroughput(struct aeEventLoop *eventLoop, long long id, void *clientData) { |
| 1644 | UNUSED(eventLoop); |
| 1645 | UNUSED(id); |
| 1646 | UNUSED(clientData); |
| 1647 | int liveclients = 0; |
| 1648 | int requests_finished = 0; |
| 1649 | int previous_requests_finished = 0; |
| 1650 | long long current_tick = mstime(); |
| 1651 | atomicGet(config.liveclients, liveclients); |
| 1652 | atomicGet(config.requests_finished, requests_finished); |
| 1653 | atomicGet(config.previous_requests_finished, previous_requests_finished); |
| 1654 | |
| 1655 | if (liveclients == 0 && requests_finished != config.requests) { |
| 1656 | fprintf(stderr,"All clients disconnected... aborting.\n"); |
| 1657 | exit(1); |
| 1658 | } |
| 1659 | if (config.num_threads && requests_finished >= config.requests) { |
| 1660 | aeStop(eventLoop); |
| 1661 | return AE_NOMORE; |
| 1662 | } |
| 1663 | if (config.csv) return 250; |
| 1664 | if (config.idlemode == 1) { |
| 1665 | printf("clients: %d\r", config.liveclients); |
| 1666 | fflush(stdout); |
| 1667 | return 250; |
| 1668 | } |
| 1669 | const float dt = (float)(current_tick-config.start)/1000.0; |
| 1670 | const float rps = (float)requests_finished/dt; |
| 1671 | const float instantaneous_dt = (float)(current_tick-config.previous_tick)/1000.0; |
| 1672 | const float instantaneous_rps = (float)(requests_finished-previous_requests_finished)/instantaneous_dt; |
| 1673 | config.previous_tick = current_tick; |
| 1674 | atomicSet(config.previous_requests_finished,requests_finished); |
| 1675 | int printed_bytes = printf("%s: rps=%.1f (overall: %.1f) avg_msec=%.3f (overall: %.3f)\r", config.title, instantaneous_rps, rps, hdr_mean(config.current_sec_latency_histogram)/1000.0f, hdr_mean(config.latency_histogram)/1000.0f); |
| 1676 | if (printed_bytes > config.last_printed_bytes){ |
| 1677 | config.last_printed_bytes = printed_bytes; |
| 1678 | } |
| 1679 | hdr_reset(config.current_sec_latency_histogram); |
| 1680 | fflush(stdout); |
| 1681 | return 250; /* every 250ms */ |
| 1682 | } |
| 1683 | |
| 1684 | /* Return true if the named test was selected using the -t command line |
| 1685 | * switch, or if all the tests are selected (no -t passed by user). */ |