-
-
Save geerlingguy/570e13f4f81a40a5395688667b1f79af to your computer and use it in GitHub Desktop.
| #!/bin/bash | |
| # | |
| # Benchmark script for SBCs (Debian or Ubuntu). | |
| # | |
| # WARNING: This script is meant to be run as the root user. | |
| # This script should never be run on a system/partition you | |
| # care about. You should only run this on a system that you | |
| # intend to use only for benchmarking and can reinstall or | |
| # re-flash easily. | |
| # | |
| # It's a good idea to make sure your system is updated prior | |
| # to running this script: | |
| # | |
| # sudo apt-get update | |
| # sudo apt-get dist-upgrade -y | |
| # | |
| # Usage: | |
| # sudo ./pi-general-benchmark.sh | |
| # | |
| # To set a different PHP_VERSION (e.g. if you're on a newer OS): | |
| # sudo PHP_VERSION="8.3" ./pi-general-benchmark.sh | |
| # Fail on error. | |
| set -e | |
| # Allow PHP_VERSION to be overridden. | |
| PHP_VERSION="${PHP_VERSION:-8.2}" | |
| PTS_VERSION="${PTS_VERSION:-10.8.4}" | |
| # Set this to "~/.phoronix-test-suite" if not running as root. | |
| PHORONIX_CONFIG_PATH="/var/lib/phoronix-test-suite" | |
| # Verify script is running as root. | |
| if [ "$EUID" -ne 0 ] | |
| then echo "Please run this script as root (e.g. with sudo)." | |
| exit | |
| fi | |
| # Change directories into home folder. | |
| cd ~ | |
| # Install prerequisites. | |
| source /etc/os-release | |
| case $ID in | |
| debian|ubuntu|mint) | |
| apt-get install -y php${PHP_VERSION}-cli php${PHP_VERSION}-xml | |
| ;; | |
| fedora|rhel|centos|rocky) | |
| dnf install -y php-cli php-xml | |
| ;; | |
| *) | |
| echo -n "Unsupported Linux distribution." | |
| ;; | |
| esac | |
| # Download test suite. | |
| curl -LO https://www.phoronix-test-suite.com/releases/phoronix-test-suite-${PTS_VERSION}.tar.gz | |
| tar -xvf phoronix-test-suite-${PTS_VERSION}.tar.gz | |
| cd phoronix-test-suite | |
| # Accept terms and print system info. | |
| ./phoronix-test-suite system-info <<-END | |
| y | |
| n | |
| n | |
| END | |
| # List recommended tests. | |
| # ./phoronix-test-suite list-recommended-tests | |
| # Batch setup | |
| # Thanks to https://stackoverflow.com/a/77707788/100134 for the assist. | |
| printf 'y\nn\nn\nn\nn\nn\nn\n' | ./phoronix-test-suite batch-setup | |
| # Install test suites. | |
| ./phoronix-test-suite install pts/encode-mp3 | |
| ./phoronix-test-suite install pts/x264 | |
| ./phoronix-test-suite install pts/phpbench | |
| ./phoronix-test-suite install pts/build-linux-kernel | |
| # Run standard test suites. | |
| ./phoronix-test-suite batch-run pts/encode-mp3 | |
| ./phoronix-test-suite batch-run pts/phpbench | |
| # Run test suite requiring option selection. | |
| echo 3 | ./phoronix-test-suite batch-run pts/x264 | |
| echo 1 | ./phoronix-test-suite batch-run pts/build-linux-kernel |
I've also updated the Gist to work on Fedora/RHEL/Rocky Linux/CentOS.
For macOS, I will need to make a few changes, like:
- Document that Homebrew should already be installed
- Set
PHORONIX_CONFIG_PATH="~/.phoronix-test-suite" - Remove the
if [ "$EUID" -ne 0 ]root user requirement - Tweak the distro detection PHP installation bit, to add Darwin and set up
brew install php
I am a little surprised the Phoronix suite has no "default target"...
Going to run this on SpacemiT x100 chips. Thank you for sharing this script; just saved me hours from "quickly" learning how to use that suite lol.
@IngwiePhoenix - Haha yes, I think the problem is @michaellarabel targets so many different platforms, it is almost impossible to have a default suite that will run across all and give results that make sense to share, especially as new systems roll out (similar to like, Geekbench).
Like right now I haven't been able to get RISC-V chips to run the MP3 test at all, and usually there are problems with x264 as well...
I've just added env vars to override
PHP_VERSIONandPTS_VERSION, making it easier to run on different OSes like Debian 12 (PHP 8.2) or Ubuntu 24.04 (PHP 8.3) without modifying the script.