From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45399) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VZpu3-0006ry-NB for qemu-devel@nongnu.org; Fri, 25 Oct 2013 18:30:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VZpu1-0002N2-JM for qemu-devel@nongnu.org; Fri, 25 Oct 2013 18:30:47 -0400 Received: from mail.avalus.com ([2001:41c8:10:1dd::10]:45575) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VZpu0-0002Mg-R9 for qemu-devel@nongnu.org; Fri, 25 Oct 2013 18:30:45 -0400 From: Alex Bligh Date: Fri, 25 Oct 2013 23:30:33 +0100 Message-Id: <1382740234-21345-4-git-send-email-alex@alex.org.uk> In-Reply-To: <1382740234-21345-1-git-send-email-alex@alex.org.uk> References: <1382740234-21345-1-git-send-email-alex@alex.org.uk> Subject: [Qemu-devel] [PATCHv1 3/4] Timers: Instrument timer_mod List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Kevin Wolf , Anthony Liguori , Alex Bligh , Jan Kiszka , liu ping fan , Stefan Hajnoczi , Paolo Bonzini , MORITA Kazutaka , rth@twiddle.net Add instrumentation for timer_mod to allow measurement of the average time delta to expiry plus the number of short delta periods. This is only run when logging to a file because getting the clock value may add appreciable expense. Signed-off-by: Alex Bligh --- qemu-timer.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/qemu-timer.c b/qemu-timer.c index 84a8932..16eaa1f 100644 --- a/qemu-timer.c +++ b/qemu-timer.c @@ -376,6 +376,23 @@ static bool timer_mod_ns_locked(QEMUTimerList *timer_list, ts->next = *pt; *pt = ts; + if (timer_debug_log) { + int64_t delta; + + delta = ts->expire_time - + qemu_clock_get_ns(ts->timer_list->clock->type); + if (delta <= 0) { + delta = 0; + } + + ts->tot_deltas += delta; + ts->num_deltas++; + + if (delta < SCALE_US) { + ts->num_short++; + } + } + return pt == &timer_list->active_timers; } -- 1.7.9.5