Update benchmark_disque.sh
This commit is contained in:
parent
0af01862f8
commit
b89ba14c72
1 changed files with 17 additions and 3 deletions
|
|
@ -7,15 +7,16 @@ FILESIZE="1G"
|
|||
FILECOUNT=1000
|
||||
FILEMODE="fixed"
|
||||
LINES=1
|
||||
FLUSH_CACHE="no"
|
||||
|
||||
# Fonction pour convertir "M:SS.xxx" ou "S.xxx" en secondes float
|
||||
# Fonction pour convertir "M:SS.xxx" en secondes float
|
||||
convert_time_to_sec() {
|
||||
local raw="$1"
|
||||
IFS=":" read -r min sec <<< "$raw"
|
||||
echo | awk -v m="${min:-0}" -v s="${sec:-0}" 'BEGIN {
|
||||
total = (m * 60) + s;
|
||||
if (total <= 0) {
|
||||
print "0.001"; # éviter division par zéro
|
||||
print "0.001";
|
||||
} else {
|
||||
print total;
|
||||
}
|
||||
|
|
@ -30,6 +31,7 @@ function show_help {
|
|||
echo " --count=N Nombre de petits fichiers. Défaut: 1000"
|
||||
echo " --mode=MODE Mode de génération : fixed ou random. Défaut: fixed"
|
||||
echo " --lines=N Nombre de lignes pour les fichiers en mode fixed. Défaut: 1"
|
||||
echo " --flush-cache Vide les caches Linux entre écriture et lecture (nécessite root)"
|
||||
echo " --help Affiche ce message d'aide"
|
||||
echo ""
|
||||
echo "Exemples:"
|
||||
|
|
@ -59,6 +61,9 @@ for arg in "$@"; do
|
|||
--lines=*)
|
||||
LINES="${arg#*=}"
|
||||
;;
|
||||
--flush-cache)
|
||||
FLUSH_CACHE="yes"
|
||||
;;
|
||||
--help)
|
||||
show_help
|
||||
;;
|
||||
|
|
@ -86,6 +91,11 @@ echo " (~$(awk -v size="$FILESIZE" -v sec="$WRITE_SEC" 'BEGIN {
|
|||
printf "%.2f", (size * mult) / sec
|
||||
}') MB/s)"
|
||||
|
||||
if [[ "$FLUSH_CACHE" == "yes" ]]; then
|
||||
echo -e "\nVidage du cache Linux (nécessite root)..."
|
||||
sync && echo 3 > /proc/sys/vm/drop_caches
|
||||
fi
|
||||
|
||||
echo -e "\n=== Test de lecture séquentielle ==="
|
||||
READ_TIME_SEC=$( (time dd if="$TESTFILE" of=/dev/null bs="$FILESIZE" status=none) 2>&1 | grep real | awk '{print $2}' | sed 's/m/:/;s/s//')
|
||||
READ_SEC=$(convert_time_to_sec "$READ_TIME_SEC")
|
||||
|
|
@ -96,6 +106,10 @@ echo " (~$(awk -v size="$FILESIZE" -v sec="$READ_SEC" 'BEGIN {
|
|||
printf "%.2f", (size * mult) / sec
|
||||
}') MB/s)"
|
||||
|
||||
if (( $(echo "$READ_SEC < 0.01" | bc -l) )); then
|
||||
echo "(⚠️ lecture probablement en cache — résultat peu fiable)"
|
||||
fi
|
||||
|
||||
echo -e "\n=== Test IOPS sur $FILECOUNT fichiers ($FILEMODE) ==="
|
||||
|
||||
echo -n "Création : "
|
||||
|
|
@ -121,4 +135,4 @@ echo "$READ_SMALL_SEC (~$READ_SMALL_IOPS IOPS)"
|
|||
echo -e "\nNettoyage..."
|
||||
rm -rf "$BENCHDIR"
|
||||
|
||||
echo -e "\nBenchmark terminé."
|
||||
echo -e "\nBenchmark terminé."
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue