From 62e1bf8edd6b7b39bd514ed63d69c25551809c87 Mon Sep 17 00:00:00 2001 From: Jaewook Lee <11328376+jaewooklee93@users.noreply.github.com> Date: Mon, 12 Aug 2024 17:45:24 +0900 Subject: [PATCH] cpu-benchmark: better interface --- debian-cpu-benchmark/bench.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/debian-cpu-benchmark/bench.py b/debian-cpu-benchmark/bench.py index 6a56d4e..dd85205 100755 --- a/debian-cpu-benchmark/bench.py +++ b/debian-cpu-benchmark/bench.py @@ -7,20 +7,26 @@ def speed(core): output = subprocess.run( f'sysbench cpu --threads={core} run | grep "events per second"', shell=True, capture_output=True, text=True).stdout.split()[-1] - print(output) - return output + return float(output) except: print('\n' - 'sudo apt-get update && sudo apt-get install -y sysbench' + 'sudo apt-get update && sudo apt-get install -y sysbench neofetch' '\tOR' - 'brew install sysbench' + 'brew install sysbench neofetch' '\n') raise +subprocess.run('neofetch') +R, G, B, W = (f'\x1b[{x}m' for x in (31, 32, 34, 0)) df = [] +print(f'\t{G}Speed\t\t{B} Speed') +print(f'\t{G}(multicore)\t{B}(per-core)') for core in range(1, mp.cpu_count()+1): + print(f'{R}Core: {core}', end='') s = speed(core) - df.append((core, s, s/core)) + row = (core, s, s/core) + print(f'\t{G}{int(row[1]):^8}\t{B}{int(row[2]):^8}') + df.append(row) +print(W) df = pd.DataFrame(df) df.to_csv('bench.csv', index=False) -