Add a sample to the operations per second array of samples. */
| 1648 | |
| 1649 | /* Add a sample to the operations per second array of samples. */ |
| 1650 | void trackInstantaneousMetric(int metric, long long current_reading) { |
| 1651 | long long now = mstime(); |
| 1652 | long long t = now - server.inst_metric[metric].last_sample_time; |
| 1653 | long long ops = current_reading - |
| 1654 | server.inst_metric[metric].last_sample_count; |
| 1655 | long long ops_sec; |
| 1656 | |
| 1657 | ops_sec = t > 0 ? (ops*1000/t) : 0; |
| 1658 | |
| 1659 | server.inst_metric[metric].samples[server.inst_metric[metric].idx] = |
| 1660 | ops_sec; |
| 1661 | server.inst_metric[metric].idx++; |
| 1662 | server.inst_metric[metric].idx %= STATS_METRIC_SAMPLES; |
| 1663 | server.inst_metric[metric].last_sample_time = now; |
| 1664 | server.inst_metric[metric].last_sample_count = current_reading; |
| 1665 | } |
| 1666 | |
| 1667 | /* Return the mean of all the samples. */ |
| 1668 | long long getInstantaneousMetric(int metric) { |