From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45528) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XdeNs-00076u-UT for qemu-devel@nongnu.org; Mon, 13 Oct 2014 08:06:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XdeNg-0006Ks-Lp for qemu-devel@nongnu.org; Mon, 13 Oct 2014 08:05:52 -0400 Received: from mail-wi0-x22d.google.com ([2a00:1450:400c:c05::22d]:49542) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XdeNg-0006Kb-F2 for qemu-devel@nongnu.org; Mon, 13 Oct 2014 08:05:40 -0400 Received: by mail-wi0-f173.google.com with SMTP id fb4so7219225wid.0 for ; Mon, 13 Oct 2014 05:05:39 -0700 (PDT) Sender: Paolo Bonzini Message-ID: <543BC00E.2060907@redhat.com> Date: Mon, 13 Oct 2014 14:05:34 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <1411572065-18072-1-git-send-email-benoit.canet@nodalink.com> <1411572065-18072-4-git-send-email-benoit.canet@nodalink.com> In-Reply-To: <1411572065-18072-4-git-send-email-benoit.canet@nodalink.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Subject: Re: [Qemu-devel] [PATCH v3 3/3] util: Infrastructure for computing recent averages List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: =?UTF-8?B?QmVub8OudCBDYW5ldA==?= , qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, armbru@redhat.com Il 24/09/2014 17:21, BenoƮt Canet ha scritto: > The module takes care of computing minimal and maximal > values over the time slice duration. The code looks good, just two comments: > +/* Get the average value > + * > + * @ta: the timed average structure used > + * @ret: the average value > + */ > +uint64_t timed_average_avg(TimedAverage *ta) > +{ > + Window *w; > + check_expirations(ta); > + > + w = current_window(ta); > + > + if (w->count) { > + return w->sum / w->count; First, do we want this to return double? Second, this will return the min/max/avg in an unknown amount of time between period/2 and period---on average period*3/4, e.g. 0.75 seconds for a period equal to one second. Would it make sense to tweak the TimedAverage period to be higher, e.g. 1.33 seconds/80 seconds/80 minutes, so that the _average_ period is 1 second/1 minute/1 hour? This only applies to how the code is used, not to TimedAverage itself; hence, feel free to post the patch with Reviewed-by once timed_average_avg's return type is changed to a double. Paolo > + } > + > + return 0; > +} > + > +/* Get the maximum value > + * > + * @ta: the timed average structure used > + * @ret: the maximal value > + */ > +uint64_t timed_average_max(TimedAverage *ta) > +{ > + check_expirations(ta); > + return current_window(ta)->max; > +} >