Did you know that macOS has a built-in game performance HUD with a frames per second (FPS) counter, similar using RivaTuner Statistics Server (RTSS) to display a GPU performance overlay in Windows? Here’s how to enable the Metal Performance HUD.

Simply run a game with the environment variable MTL_HUD_ENABLED=1:

open mygame.app --env MTL_HUD_ENABLED=1

Or set the global environment variable via launchctl. I use this in my .zhsrc file to toggle the variable on and off:

alias fps='[[ $(launchctl getenv MTL_HUD_ENABLED) -eq 1 ]]&&launchctl unsetenv MTL_HUD_ENABLED||launchctl setenv MTL_HUD_ENABLED 1'

Apple’s Discover Metal Performance HUD video explains the two types of rendering output:

  • Direct: “least buffering and fewest number of refresh intervals”
  • Composite: “additional display latency due to system UI limits”

Here are a few screenshots courtesy of two games: Tomb Raider and the open-source *OpenTyrian 2000:

Tomb Raider with the Metal Performance HUD OpenTyrian 2000 with the Metal Performance HUD

If you use xbar to show script output in the macOS menubar, you could use this metal_hud.1d.sh:

# <xbar.title>Metal Performance HUD</xbar.title>
# <xbar.author>C.Y. Wong, myByways.com</xbar.author>
# <xbar.abouturl>https://mybyways.com/blog/enabling-the-macos-metal-performance-hud</xbar.abouturl>
[[ $(launchctl getenv MTL_HUD_ENABLED) -eq 1 ]] && echo 📈 || echo 📉
echo ---
echo Enable Metal Performance HUD\|refresh=true\|shell=launchctl\|param1=setenv\|param2=MTL_HUD_ENABLED\|param3=1
echo Disable Metal Performance HUD\|refresh=true\|shell=launchctl\|param1=unsetenv\|param2=MTL_HUD_ENABLED

I’ll post more of my xbar plugins one day!