-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbenchmark.sh
31 lines (22 loc) · 1.02 KB
/
benchmark.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/bin/bash
# Check if sysbench is installed, install it if not
if ! command -v sysbench &> /dev/null; then
echo "Installing sysbench..."
sudo apt update && sudo apt install -y sysbench
fi
# Record the current Unix timestamp
TIMESTAMP=$(date +%s)
# Run CPU benchmark
CPU=$(sysbench cpu run --time=60 | grep 'events per second' | awk '{print $4}')
# Run memory benchmark
MEMORY=$(sysbench memory run --time=60 --memory-block-size=4K --memory-total-size=100TB | grep 'transferred' | awk '{print $1}')
# Prepare disk benchmark files
sysbench fileio --file-total-size=1G prepare
# Run random disk read benchmark
DISK_RAND=$(sysbench fileio --file-total-size=1G --file-test-mode=rndrd run | grep 'read, MiB/s' | awk '{print $1}')
# Run sequential disk read benchmark
DISK_SEQ=$(sysbench fileio --file-total-size=1G --file-test-mode=seqrd run | grep 'read, MiB/s' | awk '{print $1}')
# Cleanup disk benchmark files
sysbench fileio cleanup
# Print results in CSV format
echo "${TIMESTAMP},${CPU},${MEMORY},${DISK_RAND},${DISK_SEQ}"