• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Copyright (C) 2022 The Android Open Source Project
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//      http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15import m from 'mithril';
16
17import {Probe, ProbeAttrs, Slider, SliderAttrs} from '../record_widgets';
18import {POLL_INTERVAL_MS, RecordingSectionAttrs} from './recording_sections';
19
20export class CpuSettings implements m.ClassComponent<RecordingSectionAttrs> {
21  view({attrs}: m.CVnode<RecordingSectionAttrs>) {
22    return m(
23        `.record-section${attrs.cssClass}`,
24        m(Probe,
25          {
26            title: 'Coarse CPU usage counter',
27            img: 'rec_cpu_coarse.png',
28            descr: `Lightweight polling of CPU usage counters via /proc/stat.
29                    Allows to periodically monitor CPU usage.`,
30            setEnabled: (cfg, val) => cfg.cpuCoarse = val,
31            isEnabled: (cfg) => cfg.cpuCoarse,
32          } as ProbeAttrs,
33          m(Slider, {
34            title: 'Poll interval',
35            cssClass: '.thin',
36            values: POLL_INTERVAL_MS,
37            unit: 'ms',
38            set: (cfg, val) => cfg.cpuCoarsePollMs = val,
39            get: (cfg) => cfg.cpuCoarsePollMs,
40          } as SliderAttrs)),
41        m(Probe, {
42          title: 'Scheduling details',
43          img: 'rec_cpu_fine.png',
44          descr: 'Enables high-detailed tracking of scheduling events',
45          setEnabled: (cfg, val) => cfg.cpuSched = val,
46          isEnabled: (cfg) => cfg.cpuSched,
47        } as ProbeAttrs),
48        m(Probe,
49          {
50            title: 'CPU frequency and idle states',
51            img: 'rec_cpu_freq.png',
52            descr:
53                'Records cpu frequency and idle state changes via ftrace and sysfs',
54            setEnabled: (cfg, val) => cfg.cpuFreq = val,
55            isEnabled: (cfg) => cfg.cpuFreq,
56          } as ProbeAttrs,
57          m(Slider, {
58            title: 'Sysfs poll interval',
59            cssClass: '.thin',
60            values: POLL_INTERVAL_MS,
61            unit: 'ms',
62            set: (cfg, val) => cfg.cpuFreqPollMs = val,
63            get: (cfg) => cfg.cpuFreqPollMs,
64          } as SliderAttrs)),
65        m(Probe, {
66          title: 'Syscalls',
67          img: 'rec_syscalls.png',
68          descr: `Tracks the enter and exit of all syscalls. On Android
69                requires a userdebug or eng build.`,
70          setEnabled: (cfg, val) => cfg.cpuSyscall = val,
71          isEnabled: (cfg) => cfg.cpuSyscall,
72        } as ProbeAttrs));
73  }
74}
75