-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathintelpower_performance.go
64 lines (51 loc) · 1.34 KB
/
intelpower_performance.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package intelpower
import (
"errors"
"strconv"
)
// GetMinPerf - Returns min performance percent
func (pwr *IntelPower) GetMinPerf() (float32, error) {
resp, err := pwr.cmdRead(pwr.flRoot, "intel_pstate", "min_perf_pct")
if err != nil {
return 0, err
}
pct, err := strconv.ParseFloat(resp, 32)
if err != nil {
return 0, err
}
return float32(pct / 100), nil
}
// SetMinPerf - Sets min performance percent
func (pwr *IntelPower) SetMinPerf(prc float32) error {
if prc < 0 || prc > 1 {
return NewCommonError(errors.New("percent must be in [0..1]"))
}
err := pwr.cmdWrite(strconv.Itoa(int(prc*100)), pwr.flRoot, "intel_pstate", "min_perf_pct")
if err != nil {
return err
}
return nil
}
// GetMaxPerf - Returns max performance percent
func (pwr *IntelPower) GetMaxPerf() (float32, error) {
resp, err := pwr.cmdRead(pwr.flRoot, "intel_pstate", "max_perf_pct")
if err != nil {
return 0, err
}
pct, err := strconv.ParseFloat(resp, 32)
if err != nil {
return 0, err
}
return float32(pct / 100), nil
}
// SetMaxPerf - Sets max performance percent
func (pwr *IntelPower) SetMaxPerf(prc float32) error {
if prc < 0 || prc > 1 {
return NewCommonError(errors.New("percent must be in [0..1]"))
}
err := pwr.cmdWrite(strconv.Itoa(int(prc*100)), pwr.flRoot, "intel_pstate", "max_perf_pct")
if err != nil {
return err
}
return nil
}