From mboxrd@z Thu Jan 1 00:00:00 1970 From: George Dunlap Subject: [PATCH 5 of 8] xenalyze: Rework math to remove two 64-bit divisions Date: Thu, 26 Jan 2012 17:21:02 +0000 Message-ID: <4b3639bd32550d40bfc4.1327598462@elijah> References: Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com Cc: george.dunlap@eu.citrix.com List-Id: xen-devel@lists.xenproject.org abs_cycles_to_time is called on every record for dump mode; it has four 64-bit divisions (well, 3 divisions and 1 mod), which map to library functions on a 32-bit platform. A simple rework of the math can eliminate two of those. Signed-off-by: George Dunlap diff -r 0663e3e8f69d -r 4b3639bd3255 xenalyze.c --- a/xenalyze.c Thu Jan 26 17:16:59 2012 +0000 +++ b/xenalyze.c Thu Jan 26 17:17:19 2012 +0000 @@ -1976,16 +1976,19 @@ void cpumask_union(cpu_mask_t *d, const /* -- Time code -- */ void cycles_to_time(unsigned long long c, struct time_struct *t) { - t->time = ((c) * 1000) / (opt.cpu_hz / 1000000 ); - t->s = t->time / 1000000000; - t->ns = t->time % 1000000000; + t->time = ((c - P.f.first_tsc) * 1000 * 1000000) / opt.cpu_hz; + t->s = t->time / 1000000000; + t->ns = t->time - (t->s * 1000000000); } void abs_cycles_to_time(unsigned long long ac, struct time_struct *t) { if(ac > P.f.first_tsc) { - t->time = ((ac - P.f.first_tsc) * 1000) / (opt.cpu_hz / 1000000 ); - t->s = t->time / 1000000000; - t->ns = t->time % 1000000000; + /* t->time = ((ac - P.f.first_tsc) * 1000) / (opt.cpu_hz / 1000000 ); */ + /* t->s = t->time / 1000000000; */ + /* t->ns = t->time % 1000000000; */ + t->time = ((ac - P.f.first_tsc) * 1000 * 1000000) / opt.cpu_hz; + t->s = t->time / 1000000000; + t->ns = t->time - (t->s * 1000000000); } else { t->time = t->s = t->ns = 0; }