Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Unified Diff: tools/cpu.sh

Issue 1458833004: Allow specifying cores for cpu.sh script. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/cpu.sh
diff --git a/tools/cpu.sh b/tools/cpu.sh
index 0597d09ea99647eae832b755e9b59995a3f1d4d0..5634cac9395953778b09a76dd5d344138e12ea5f 100755
--- a/tools/cpu.sh
+++ b/tools/cpu.sh
@@ -14,26 +14,38 @@ set_governor() {
done
}
+enable_cores() {
+ # $1: How many cores to enable.
+ for (( i=1; i<=$MAXID; i++ )); do
+ if [ "$i" -lt "$1" ]; then
+ echo 1 > $CPUPATH/cpu$i/online
+ else
+ echo 0 > $CPUPATH/cpu$i/online
+ fi
+ done
+}
+
dual_core() {
echo "Switching to dual-core mode"
- for (( i=2; i<=$MAXID; i++ )); do
- echo 0 > $CPUPATH/cpu$i/online
- done
+ enable_cores 2
}
single_core() {
echo "Switching to single-core mode"
- for (( i=1; i<=$MAXID; i++ )); do
- echo 0 > $CPUPATH/cpu$i/online
- done
+ enable_cores 1
}
all_cores() {
echo "Reactivating all CPU cores"
- for (( i=1; i<=$MAXID; i++ )); do
- echo 1 > $CPUPATH/cpu$i/online
- done
+ enable_cores $((MAXID+1))
+}
+
+
+limit_cores() {
+ # $1: How many cores to enable.
+ echo "Limiting to $1 cores"
+ enable_cores $1
}
case "$1" in
@@ -55,8 +67,15 @@ case "$1" in
allcores | all)
all_cores
;;
+ limit_cores)
+ if [ $# -ne 2 ]; then
+ echo "Usage $0 limit_cores <num>"
+ exit 1
+ fi
+ limit_cores $2
+ ;;
*)
- echo "Usage: $0 fast|slow|default|singlecore|dualcore|all"
+ echo "Usage: $0 fast|slow|default|singlecore|dualcore|all|limit_cores"
exit 1
;;
esac
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698