From ba159467f2e6f97bd7ac1e76d0d9f59d4656891b Mon Sep 17 00:00:00 2001 From: Jaewook Lee <11328376+jaewooklee93@users.noreply.github.com> Date: Mon, 12 Aug 2024 17:05:58 +0900 Subject: [PATCH] debian-cpu-benchmark add sysbench install guide --- debian-cpu-benchmark/bench.py | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) 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)