in progress
This commit is contained in:
@@ -1,43 +1,43 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
def ensure(*packages):
|
||||
for pkg in packages:
|
||||
try: __import__(pkg)
|
||||
except: import os; os.system(f'pip install -q {pkg}')
|
||||
ensure('pandas', 'tabulate')
|
||||
|
||||
import subprocess, multiprocessing as mp, warnings, pandas as pd
|
||||
from tqdm.auto import tqdm
|
||||
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')
|
||||
|
||||
command = lambda core: f'sysbench cpu --cpu-max-prime=20000 --time=1 --threads={core} run | grep second'
|
||||
|
||||
print(f'{G}$ {command("$(nproc)")}{W}', flush=True)
|
||||
|
||||
|
||||
def speed(core):
|
||||
output = subprocess.run(
|
||||
command(core), shell=True, capture_output=True, text=True
|
||||
).stdout.split()[-1]
|
||||
return float(output)
|
||||
|
||||
df = []
|
||||
for core in range(1, mp.cpu_count()+1):
|
||||
s = speed(core)
|
||||
row = {
|
||||
'#Threads': core,
|
||||
'Throughput(/s)': s,
|
||||
'(per-core)': s/core
|
||||
}
|
||||
df.append(row)
|
||||
df = pd.DataFrame(df)
|
||||
df.to_csv('result.csv', index=False)
|
||||
|
||||
df.iloc[:, 0] = df.iloc[:, 0].apply(lambda s: f'{R}{s}{W}')
|
||||
df.iloc[:, 1] = df.iloc[:, 1].apply(lambda s: f'{G}{int(s)}{W}')
|
||||
df.iloc[:, 2] = df.iloc[:, 2].apply(lambda s: f'{B}{int(s)}{W}')
|
||||
print(tabulate(df, headers='keys', tablefmt='rounded_outline', showindex=False))
|
||||
#!/usr/bin/env python
|
||||
|
||||
def ensure(*packages):
|
||||
for pkg in packages:
|
||||
try: __import__(pkg)
|
||||
except: import os; os.system(f'pip install -q {pkg}')
|
||||
ensure('pandas', 'tabulate')
|
||||
|
||||
import subprocess, multiprocessing as mp, warnings, pandas as pd
|
||||
from tqdm.auto import tqdm
|
||||
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')
|
||||
|
||||
command = lambda core: f'sysbench cpu --cpu-max-prime=20000 --time=1 --threads={core} run | grep second'
|
||||
|
||||
print(f'{G}$ {command("$(nproc)")}{W}', flush=True)
|
||||
|
||||
|
||||
def speed(core):
|
||||
output = subprocess.run(
|
||||
command(core), shell=True, capture_output=True, text=True
|
||||
).stdout.split()[-1]
|
||||
return float(output)
|
||||
|
||||
df = []
|
||||
for core in range(1, mp.cpu_count()+1):
|
||||
s = speed(core)
|
||||
row = {
|
||||
'#Threads': core,
|
||||
'Throughput(/s)': s,
|
||||
'(per-core)': s/core
|
||||
}
|
||||
df.append(row)
|
||||
df = pd.DataFrame(df)
|
||||
df.to_csv('result.csv', index=False)
|
||||
|
||||
df.iloc[:, 0] = df.iloc[:, 0].apply(lambda s: f'{R}{s}{W}')
|
||||
df.iloc[:, 1] = df.iloc[:, 1].apply(lambda s: f'{G}{int(s)}{W}')
|
||||
df.iloc[:, 2] = df.iloc[:, 2].apply(lambda s: f'{B}{int(s)}{W}')
|
||||
print(tabulate(df, headers='keys', tablefmt='rounded_outline', showindex=False))
|
||||
|
||||
Reference in New Issue
Block a user