Skip to content

Instantly share code, notes, and snippets.

/winefps.sh Secret

Created October 15, 2015 13:59
Show Gist options
  • Star 9 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/844aefd70bb50bf72b35 to your computer and use it in GitHub Desktop.
Save anonymous/844aefd70bb50bf72b35 to your computer and use it in GitHub Desktop.
#!/bin/sh
if [ $# -eq 0 ] || [ "$1" = "-h" ]; then
cat<<EOF
Usage: ${0##*/} WIN_EXE PARAMS"
Run Wine application while displaying FPS onscreen.
EOF
exit
fi
if ! command -v osd_cat >/dev/null 2>&1; then
echo >&2 "osd_cat not found in path."
exit 1
fi
## The unbuffered option is -u on GNU and OpenBSD, -l on others.
OPT_UNBUF=-l
case "$(uname)" in
Linux|OpenBSD) OPT_UNBUF=-u ;;
esac
WINEDEBUG=fps wine "$@" 2>&1 | tee /dev/stderr | \
sed $OPT_UNBUF -n '/^trace:fps:/{s/.* \([^ ]*\)fps/\1/;p}' | \
osd_cat -l1 -f "-*-*-*-*-*-*-32-*-*-*-*-*-*-*" -O1 -c "yellow"
@Mrestof
Copy link

Mrestof commented Feb 9, 2022

A little critique, not to blame someone, but to help others

  1. Won't work if you run wine under another user, not the user who was logged in first and started the X session, because the second user doesn't have rights to the /dev/stderr of the first user. Here is the link to the info source.
  2. The sed command is a bit different in my case (or maybe it's a wine's log system change). The part trace:fps... is not at the beginning of each line, but right after some number. My log string looks like this: 0024:trace:fps:wglSwapBuffers @ approx 55.30fps, total 38.05fps.

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