| # Copyright 2014 the V8 project authors. All rights reserved. |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| CPUPATH=/sys/devices/system/cpu |
| MAXID=$(cat $CPUPATH/present | awk -F- '{print $NF}') |
| echo "Setting CPU frequency governor to \"$1\"" |
| for (( i=0; i<=$MAXID; i++ )); do |
| echo "$1" > $CPUPATH/cpu$i/cpufreq/scaling_governor |
| # $1: How many cores to enable. |
| for (( i=1; i<=$MAXID; i++ )); do |
| if [ "$i" -lt "$1" ]; then |
| echo 1 > $CPUPATH/cpu$i/online |
| echo 0 > $CPUPATH/cpu$i/online |
| echo "Switching to dual-core mode" |
| echo "Switching to single-core mode" |
| echo "Reactivating all CPU cores" |
| enable_cores $((MAXID+1)) |
| # $1: How many cores to enable. |
| echo "Limiting to $1 cores" |
| set_governor "performance" |
| echo "Usage $0 limit_cores <num>" |
| echo "Usage: $0 fast|slow|default|singlecore|dualcore|all|limit_cores" |