cpu-bench: add clear
This commit is contained in:
@@ -1,16 +1,26 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
def ensure(*packages):
|
||||
for pkg in packages:
|
||||
try: __import__(pkg)
|
||||
except: import os; os.sytem(f'pip install -q {pkg}')
|
||||
ensure('pandas', 'tabulate')
|
||||
|
||||
import subprocess, multiprocessing as mp, warnings, pandas as pd
|
||||
from tabulate import tabulate
|
||||
warnings.filterwarnings("ignore")
|
||||
R, G, B, W = (f'\x1b[{x}m' for x in (31, 32, 34, 0))
|
||||
subprocess.run('clear')
|
||||
subprocess.run('neofetch')
|
||||
print(f'{G}$ sysbench cpu --cpu-max-prime=20000 --time=1 --threads=$(nproc) run | grep second{W}')
|
||||
|
||||
command = lambda core: f'sysbench cpu --cpu-max-prime=20000 --time=1 --threads={core} run | grep second'
|
||||
|
||||
print(f'{G}$ {command("$(nproc)")}{W}')
|
||||
|
||||
def speed(core):
|
||||
output = subprocess.run(
|
||||
f'sysbench cpu --cpu-max-prime=20000 --time=1 --threads={core} run | grep second',
|
||||
shell=True, capture_output=True, text=True).stdout.split()[-1]
|
||||
command(core), shell=True, capture_output=True, text=True
|
||||
).stdout.split()[-1]
|
||||
return float(output)
|
||||
|
||||
df = []
|
||||
@@ -18,7 +28,7 @@ for core in range(1, mp.cpu_count()+1):
|
||||
s = speed(core)
|
||||
row = {
|
||||
'#Threads': core,
|
||||
'Throughput': s,
|
||||
'Throughput(/s)': s,
|
||||
'(per-core)': s/core
|
||||
}
|
||||
df.append(row)
|
||||
|
||||
Reference in New Issue
Block a user