From efc32d0cab1ee6e52626c0bd59b1929bbd2b2bbe Mon Sep 17 00:00:00 2001 From: davidmetz Date: Mon, 16 Mar 2020 21:08:04 +0100 Subject: Fix CPI calcualtion for -s option (#192) This attempt at rounding leads to wrong results, for example: 314689951 cycles 314690101 instructions 0.90 CPI With my change results in: 314689951 cycles 314690101 instructions 0.99 CPI I think this was supposed to be part of rounding behaviour but it doesn't work if only the final digit does it and there is no carry... Instead I changed it to truncate after the second digit --- pk/syscall.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'pk') diff --git a/pk/syscall.c b/pk/syscall.c index 4978f3a..8101ec9 100644 --- a/pk/syscall.c +++ b/pk/syscall.c @@ -24,7 +24,7 @@ void sys_exit(int code) printk("%lld cycles\n", dc); printk("%lld instructions\n", di); printk("%d.%d%d CPI\n", (int)(dc/di), (int)(10ULL*dc/di % 10), - (int)((100ULL*dc + di/2)/di % 10)); + (int)((100ULL*dc)/di % 10)); } shutdown(code); } -- cgit v1.1