Last active
October 13, 2024 20:38
-
-
Save cheeseonamonkey/6ac626463c2d93dc4a25739aae5b4be5 to your computer and use it in GitHub Desktop.
bcache_benchmarker.zsh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/zsh | |
# Define paths and test file size | |
TEST_FILE_SIZE=1024 # Size in MB (1G = 1024MB) | |
TEST_FILE_PATH_ROOT="/testfile" | |
TEST_FILE_PATH_HDD="/hdd/testfile" | |
# Clear bcache stats | |
echo "Clearing bcache stats..." | |
echo 1 | sudo tee /sys/block/bcache0/bcache/clear_stats > /dev/null | |
# Create test files | |
echo "Creating test files..." | |
sudo dd if=/dev/zero of=$TEST_FILE_PATH_ROOT bs=1M count=$TEST_FILE_SIZE status=progress | |
sudo dd if=/dev/zero of=$TEST_FILE_PATH_HDD bs=1M count=$TEST_FILE_SIZE status=progress | |
# Measure performance without cache | |
echo "Measuring performance without cache..." | |
sudo hdparm -t /dev/sda4 | |
sudo hdparm -t /dev/sdb2 | |
# Read files multiple times to populate cache | |
echo "Reading files to populate cache..." | |
for i in {1..5}; do | |
sudo dd if=$TEST_FILE_PATH_ROOT of=/dev/null bs=1M status=progress | |
sudo dd if=$TEST_FILE_PATH_HDD of=/dev/null bs=1M status=progress | |
done | |
# Measure performance with cache | |
echo "Measuring performance with cache..." | |
sudo hdparm -t /dev/sda4 | |
sudo hdparm -t /dev/sdb2 | |
# Clean up test files | |
echo "Cleaning up test files..." | |
sudo rm -f $TEST_FILE_PATH_ROOT $TEST_FILE_PATH_HDD | |
echo "Performance test completed." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment