Last active
November 17, 2015 02:29
-
-
Save mcav/1c727f1a3c47775eaa17 to your computer and use it in GitHub Desktop.
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/bash | |
# cpulimit must be installed... | |
# - homebrew: "brew install cpulimit" | |
# - make from https://github.com/opsengine/cpulimit | |
CPULIMIT_BIN=cpulimit | |
# The CPU percentage may be, e.g. 800 for an 8-core machine. | |
# See the docs for `cpulimit`. | |
PERCENT_CPU=50 | |
# Perpetually wait for a B2G process to appear by grepping | |
# the process list for "shell.html". | |
while true; do | |
# pgrep's "-f" option is used to search the argument lists as well. | |
for pid in `pgrep -f shell.html`; do | |
# cpulimit will block until the process exits, which is ideal when | |
# running "make test-integration" as it runs one instance at a time. | |
$CPULIMIT_BIN -l ${PERCENT_CPU} -p ${pid} | |
done | |
# and then we search again after a moment. | |
sleep 0.1 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment