Skip to content

Instantly share code, notes, and snippets.

@geerlingguy
Last active August 3, 2026 16:26
Show Gist options
  • Select an option

  • Save geerlingguy/570e13f4f81a40a5395688667b1f79af to your computer and use it in GitHub Desktop.

Select an option

Save geerlingguy/570e13f4f81a40a5395688667b1f79af to your computer and use it in GitHub Desktop.
SBC Benchmark Suite - Phoronix
#!/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
#
# PTS is cloned from git master, since the last tagged release
# (10.8.4, from 2022) predates fixes for newer PHP releases. To
# pin a specific ref (tag, branch, or commit) instead:
# sudo PTS_REF="v10.8.4" ./pi-general-benchmark.sh
# Fail on error.
set -e
# Allow the PTS git ref to be overridden.
PTS_REF="${PTS_REF:-master}"
# 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 git php-cli php-xml
;;
fedora|rhel|centos|rocky)
dnf install -y git php-cli php-xml
;;
*)
echo -n "Unsupported Linux distribution."
;;
esac
# Download test suite (shallow clone of the requested ref).
rm -rf phoronix-test-suite
git clone --depth=1 --branch "${PTS_REF}" \
https://github.com/phoronix-test-suite/phoronix-test-suite.git
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
@geerlingguy

Copy link
Copy Markdown
Author

I added pts/build-linux-kernel with just defconfig but that doesn't seem to be working out... it runs both that and all deps.

  <Execute>
    <Test>pts/build-linux-kernel</Test>
    <Arguments>defconfig</Arguments>
  </Execute>

@geerlingguy

geerlingguy commented Nov 4, 2023

Copy link
Copy Markdown
Author

I took out the build-linux-kernel test because it doesn't seem to accept the argument, it just runs all options which means it takes forever.

You can run it separately:

./phoronix-test-suite benchmark pts/build-linux-kernel

@geerlingguy

Copy link
Copy Markdown
Author

Reworked the script to just run everything individually, instead of setting up a custom batch. This way it is completely automated. Well, should be, at least.

@geerlingguy

Copy link
Copy Markdown
Author

Fixed the script to make sure all the tests are installed prior to being run. Otherwise... it just errors out.

@deepak-coding-art

Copy link
Copy Markdown

I got error when try to run these test on my pi-zero 2 running Debian GNU/Linux 11 (bullseye) aarch64
For some reason when i try to install the packages

sudo apt install -y php8.2-cli php8.2-xml

got errors:

E: Unable to locate package php8.2-cli
E: Couldn't find any package by glob 'php8.2-cli'
E: Unable to locate package php8.2-xml
E: Couldn't find any package by glob 'php8.2-xml'

Does this script do not work on debian 11

@geerlingguy

Copy link
Copy Markdown
Author

@deepak-coding-art - This script is meant for Debian 12 (or current version), but you can modify the PHP versions by changing 8.2 in them to I think 8.1 or 8.0 (whichever works on Debian 11).

@deepak-coding-art

deepak-coding-art commented Oct 21, 2024

Copy link
Copy Markdown

Thanks it worked i just needed to add the deb.sury.org repository for php

@boseabhishek

boseabhishek commented Nov 1, 2024

Copy link
Copy Markdown

Hello @geerlingguy thanks for the awesome script. All the other benchmarks seems to run fine on my Ubuntu 22.04.05 (64 bit LTS) on RPI 4B except pts/build-linux-kernel which takes a very long time ( I had to terminate it twice after 3 hours or so).

Does that sound dubious? If not, any alternative suite I could use? Thanks.

@geerlingguy

Copy link
Copy Markdown
Author

@boseabhishek - It shouldn't take that long, unless maybe you have a very slow microSD card you're booting from. It normally takes 1-2 hours on a Pi 4 - see geerlingguy/sbc-reviews#4

@boseabhishek

Copy link
Copy Markdown

Thanks @geerlingguy for the link. I'm using a 64 GB USB stick to boot from and all other suites did pretty well. But, again I'll dig deeper. Thanks for your reply again.

@geerlingguy

Copy link
Copy Markdown
Author

I've just added env vars to override PHP_VERSION and PTS_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.

@geerlingguy

Copy link
Copy Markdown
Author

I've also updated the Gist to work on Fedora/RHEL/Rocky Linux/CentOS.

@geerlingguy

geerlingguy commented Dec 8, 2025

Copy link
Copy Markdown
Author

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

@IngwiePhoenix

Copy link
Copy Markdown

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.

@geerlingguy

Copy link
Copy Markdown
Author

@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...

@geerlingguy

Copy link
Copy Markdown
Author

I updated the script to git clone PTS at PTS_REF instead of installing 10.8.4. It doesn't seem like version tags propagate to releases anymore, and you're meant to just 'run from master'. Which seems a little annoying since I like targeting releases for benchmark tools... but oh well :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment