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

Side by Side Diff: tools/cpu.sh

Issue 485763003: Check in "cpu.sh" script to control CPU governor/cores on Linux (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 4 months 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/bin/bash
2 # Copyright 2014 the V8 project authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
5
6 CPUPATH=/sys/devices/system/cpu
7
8 MAXID=$(cat $CPUPATH/present | awk -F- '{print $NF}')
9
10 set_governor() {
11 echo "Setting CPU frequency governor to \"$1\""
12 for (( i=0; i<=$MAXID; i++ )); do
13 echo "$1" > $CPUPATH/cpu$i/cpufreq/scaling_governor
14 done
15 }
16
17 dual_core() {
18 echo "Switching to dual-core mode"
19 for (( i=2; i<=$MAXID; i++ )); do
20 echo 0 > $CPUPATH/cpu$i/online
21 done
22 }
23
24 single_core() {
25 echo "Switching to single-core mode"
26 for (( i=1; i<=$MAXID; i++ )); do
27 echo 0 > $CPUPATH/cpu$i/online
28 done
29 }
30
31
32 all_cores() {
33 echo "Reactivating all CPU cores"
34 for (( i=2; i<=$MAXID; i++ )); do
35 echo 1 > $CPUPATH/cpu$i/online
36 done
37 }
38
39 case "$1" in
40 fast | performance)
41 set_governor "performance"
42 ;;
43 slow | powersave)
44 set_governor "powersave"
45 ;;
46 default | ondemand)
47 set_governor "ondemand"
48 ;;
49 dualcore | dual)
50 dual_core
51 ;;
52 singlecore | single)
53 single_core
54 ;;
55 allcores | all)
56 all_cores
57 ;;
58 *)
59 echo "Usage: $0 fast|slow|default|singlecore|dualcore|all"
60 exit 1
61 ;;
62 esac
OLDNEW
« 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