MCPcopy Create free account
hub / github.com/F-Stack/f-stack / trackInstantaneousMetric

Function trackInstantaneousMetric

app/redis-6.2.6/src/server.c:1650–1665  ·  view source on GitHub ↗

Add a sample to the operations per second array of samples. */

Source from the content-addressed store, hash-verified

1648
1649/* Add a sample to the operations per second array of samples. */
1650void 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. */
1668long long getInstantaneousMetric(int metric) {

Callers 1

serverCronFunction · 0.85

Calls 1

mstimeFunction · 0.70

Tested by

no test coverage detected