aboutsummaryrefslogtreecommitdiff
path: root/pk
diff options
context:
space:
mode:
authordavidmetz <david.metz14@googlemail.com>2020-03-16 21:08:04 +0100
committerGitHub <noreply@github.com>2020-03-16 13:08:04 -0700
commitefc32d0cab1ee6e52626c0bd59b1929bbd2b2bbe (patch)
treee69ba6e64d539ec73946e71ca04f23b6109cfd5b /pk
parent2c4e689bc1ed4440d0d95b3b350ce872e7f75865 (diff)
downloadriscv-pk-efc32d0cab1ee6e52626c0bd59b1929bbd2b2bbe.zip
riscv-pk-efc32d0cab1ee6e52626c0bd59b1929bbd2b2bbe.tar.gz
riscv-pk-efc32d0cab1ee6e52626c0bd59b1929bbd2b2bbe.tar.bz2
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
Diffstat (limited to 'pk')
-rw-r--r--pk/syscall.c2
1 files changed, 1 insertions, 1 deletions
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);
}