Skip to content

Commit 68e45b4

Browse files
RafaelGSSaduh95
authored andcommitted
benchmark,doc: add CPU scaling governor to perf
PR-URL: #54723 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
1 parent d19efd7 commit 68e45b4

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

benchmark/cpu.sh

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/bin/sh
2+
3+
CPUPATH=/sys/devices/system/cpu
4+
5+
MAXID=$(cat $CPUPATH/present | awk -F- '{print $NF}')
6+
7+
set_governor() {
8+
echo "Setting CPU frequency governor to \"$1\""
9+
i=0
10+
while [ "$i" -le "$MAXID" ]; do
11+
echo "$1" > "$CPUPATH/cpu$i/cpufreq/scaling_governor"
12+
i=$((i + 1))
13+
done
14+
}
15+
16+
case "$1" in
17+
fast | performance)
18+
set_governor "performance"
19+
;;
20+
*)
21+
echo "Usage: $0 fast"
22+
exit 1
23+
;;
24+
esac

doc/contributing/writing-and-running-benchmarks.md

+10
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,16 @@ A list of mirrors is [located here](https://cran.r-project.org/mirrors.html).
9494

9595
## Running benchmarks
9696

97+
### Setting CPU Frequency scaling governor to "performance"
98+
99+
It is recommended to set the CPU frequency to `performance` before running
100+
benchmarks. This increases the likelihood of each benchmark achieving peak performance
101+
according to the hardware. Therefore, run:
102+
103+
```console
104+
$ ./benchmarks/cpu.sh fast
105+
```
106+
97107
### Running individual benchmarks
98108

99109
This can be useful for debugging a benchmark or doing a quick performance

0 commit comments

Comments
 (0)