Software /
code /
prosody
Comparison
util/statistics.lua @ 6649:99fa40d498cc
util.statistics: Collect duration sample even if run fewer times than the sample interval
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Tue, 05 May 2015 00:48:55 +0200 |
parent | 6562:2b5ced5ca31f |
child | 7988:dc758422d896 |
comparison
equal
deleted
inserted
replaced
6648:999434eb1bbf | 6649:99fa40d498cc |
---|---|
86 return type, stats.average, stats; | 86 return type, stats.average, stats; |
87 end; | 87 end; |
88 | 88 |
89 return function (value) | 89 return function (value) |
90 n_actual_events = n_actual_events + 1; | 90 n_actual_events = n_actual_events + 1; |
91 if n_actual_events%duration_sample_interval > 0 then | 91 if n_actual_events%duration_sample_interval == 1 then |
92 last_event = (last_event%duration_max_samples) + 1; | 92 last_event = (last_event%duration_max_samples) + 1; |
93 events[last_event] = value; | 93 events[last_event] = value; |
94 end | 94 end |
95 end; | 95 end; |
96 end; | 96 end; |
111 return "duration", stats.average, stats; | 111 return "duration", stats.average, stats; |
112 end; | 112 end; |
113 | 113 |
114 return function () | 114 return function () |
115 n_actual_events = n_actual_events + 1; | 115 n_actual_events = n_actual_events + 1; |
116 if n_actual_events%duration_sample_interval > 0 then | 116 if n_actual_events%duration_sample_interval ~= 1 then |
117 return nop_function; | 117 return nop_function; |
118 end | 118 end |
119 | 119 |
120 local start_time = time(); | 120 local start_time = time(); |
121 return function () | 121 return function () |