From 04d58ba1461fd628180e1afb8f50ac443b3959a4 Mon Sep 17 00:00:00 2001 From: Jaewook Lee <11328376+jaewooklee93@users.noreply.github.com> Date: Mon, 12 Aug 2024 16:51:22 +0900 Subject: [PATCH] debian-cpu-benchmark: initial commit --- .gitignore | 1 + debian-cpu-benchmark/bench.py | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 .gitignore create mode 100644 debian-cpu-benchmark/bench.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..763513e --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.ipynb_checkpoints diff --git a/debian-cpu-benchmark/bench.py b/debian-cpu-benchmark/bench.py new file mode 100644 index 0000000..cad29dc --- /dev/null +++ b/debian-cpu-benchmark/bench.py @@ -0,0 +1,18 @@ +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 + +df = [] +for core in range(1, mp.cpu_count()+1): + s = speed(core) + df.append((core, s, s/core)) +df = pd.DataFrame(df) +df.to_csv('bench.csv', index=False) \ No newline at end of file