Comparison

util/statistics.lua @ 10314:bbc879eab1bf

util.statistics: Add a total count for rate counters, counting from server start.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Thu, 10 Oct 2019 16:58:02 +0200
parent 7988:dc758422d896
child 10883:d75d805c852f
comparison
equal deleted inserted replaced
10313:b52f916e1813 10314:bbc879eab1bf
55 return function (delta) 55 return function (delta)
56 v = v + delta; 56 v = v + delta;
57 end; 57 end;
58 end; 58 end;
59 rate = function (name) 59 rate = function (name)
60 local since, n = time(), 0; 60 local since, n, total = time(), 0, 0;
61 registry[name..":rate"] = function () 61 registry[name..":rate"] = function ()
62 total = total + n;
62 local t = time(); 63 local t = time();
63 local stats = { 64 local stats = {
64 rate = n/(t-since); 65 rate = n/(t-since);
65 count = n; 66 count = n;
67 total = total;
66 }; 68 };
67 since, n = t, 0; 69 since, n = t, 0;
68 return "rate", stats.rate, stats; 70 return "rate", stats.rate, stats;
69 end; 71 end;
70 return function () 72 return function ()