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