diff --git a/debian-cpu-benchmark/bench.py b/debian-cpu-benchmark/bench.py index ea9ac61..a89e3c0 100755 --- a/debian-cpu-benchmark/bench.py +++ b/debian-cpu-benchmark/bench.py @@ -1,17 +1,20 @@ -#!/usr/bin/env python3 - import subprocess, multiprocessing as mp, pandas as pd -subprocess.run("sudo apt-get update && sudo apt-get install -y sysbench", - shell=True, stdout=subprocess.PIPE) - def speed(core): - output = subprocess.getoutput( - f'sysbench cpu --threads={core} run | grep "events per second"') - output = float(output.split()[-1]) - print(output) - return output - + try: + 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 + except: + print('\n' + 'sudo apt-get update && sudo apt-get install -y sysbench' + '\tOR' + 'brew install sysbench' + '\n') + raise + df = [] for core in range(1, mp.cpu_count()+1): s = speed(core)