Ich habe mich an einem kleinen Python Skript versucht, um die Schreib- und Lesegeschwindigkeit
der im System vorhandenen Mountpunkte und dem Benutzerverzeichnis zu ermitteln.
Falls wer Interesse und/oder Zeit hat, es mal bei sich zu testen.
der im System vorhandenen Mountpunkte und dem Benutzerverzeichnis zu ermitteln.
Falls wer Interesse und/oder Zeit hat, es mal bei sich zu testen.
Code:
import sys
import subprocess
import os
import time
from PyQt5.QtWidgets import QApplication, QMainWindow, QLabel, QComboBox, QPushButton, QTextEdit
def get_mount_points_from_fstab(fstab_path):
mount_points = []
with open(fstab_path, 'r') as fstab_file:
for line in fstab_file:
line = line.strip()
if line and not line.startswith('#'):
tokens = line.split()
if len(tokens) >= 2:
mount_point = tokens[1]
if mount_point.startswith("/"):
mount_points.append(mount_point)
return mount_points
class DD_GUI(QMainWindow):
def __init__(self):
super().__init__()
self.setWindowTitle("HDD/SSD Speedtest")
self.initUI()
def initUI(self):
self.file_sizes = ["4G", "8G", "16G"]
self.dateigroesse_label = QLabel("Dateigröße:", self)
self.dateigroesse_label.move(10, 10)
self.dateigroesse_combobox = QComboBox(self)
self.dateigroesse_combobox.addItems(self.file_sizes)
self.dateigroesse_combobox.move(100, 10)
self.durchlaeufe_label = QLabel("Durchläufe:", self)
self.durchlaeufe_label.move(10, 40)
self.durchlaeufe_combobox = QComboBox(self)
self.durchlaeufe_combobox.addItems([str(i) for i in range(1, 11)])
self.durchlaeufe_combobox.move(100, 40)
self.mountpoint_label = QLabel("Mountpunkt:", self)
self.mountpoint_label.move(10, 70)
home_dir = os.path.expanduser("~")
mount_points = get_mount_points_from_fstab('/etc/fstab')
mount_points.append(home_dir) # Füge das Home-Verzeichnis hinzu
self.mountpoint_combobox = QComboBox(self)
self.mountpoint_combobox.addItems(mount_points)
self.mountpoint_combobox.move(100, 70)
self.start_button = QPushButton("Start", self)
self.start_button.move(280, 100)
self.start_button.clicked.connect(self.start_dd)
self.output_text = QTextEdit(self)
self.output_text.setReadOnly(True)
self.output_text.setGeometry(10, 130, 380, 150)
self.setGeometry(100, 100, 400, 300)
def start_dd(self):
file_size = self.dateigroesse_combobox.currentText()
durchlaeufe = self.durchlaeufe_combobox.currentText()
mount_point = self.mountpoint_combobox.currentText()
output_file = os.path.join(mount_point, "test")
# Schreiben der Datei
write_command = f"dd if=/dev/zero of={output_file} bs={file_size} count={durchlaeufe} iflag=fullblock 2>&1"
write_process = subprocess.Popen(write_command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
self.update_output_text("schreiben...", mount_point)
for line in write_process.stdout:
self.update_output_text(line.strip(), mount_point)
for line in write_process.stderr:
self.update_output_text(line.strip(), mount_point)
write_process.wait()
# Lesen der Datei
read_command = f"dd if={output_file} of=/dev/null bs={file_size} count={durchlaeufe} iflag=fullblock 2>&1"
read_process = subprocess.Popen(read_command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
self.update_output_text("lesen...", mount_point)
time.sleep(1) # Eine kurze Pause, um sicherzustellen, dass das Schreiben abgeschlossen ist, bevor das Lesen beginnt
for line in read_process.stdout:
self.update_output_text(line.strip(), mount_point)
for line in read_process.stderr:
self.update_output_text(line.strip(), mount_point)
read_process.wait()
# Löschen der Datei
if os.path.exists(output_file):
os.remove(output_file)
def update_output_text(self, text, mount_point=None):
if mount_point:
text = f"{mount_point}: {text}"
relevant_lines = [
"bytes", # Nur Zeilen, die "bytes" enthalten, anzeigen
"copied",
"s,"
]
for line in text.split('\n'):
if any(keyword in line for keyword in relevant_lines):
self.output_text.append(line)
if __name__ == "__main__":
app = QApplication(sys.argv)
window = DD_GUI()
window.show()
sys.exit(app.exec_())