1// Copyright (C) 2023 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 { 18 Probe, 19 ProbeAttrs, 20 Slider, 21 SliderAttrs, 22 Textarea, 23 TextareaAttrs, 24} from '../record_widgets'; 25 26import {RecordingSectionAttrs} from './recording_sections'; 27 28const PLACEHOLDER_TEXT = `Filters for processes to profile, one per line e.g.: 29com.android.phone 30lmkd 31com.android.webview:sandboxed_process*`; 32 33export interface LinuxPerfConfiguration { 34 targets: string[]; 35} 36 37export class LinuxPerfSettings 38 implements m.ClassComponent<RecordingSectionAttrs> 39{ 40 config = {targets: []} as LinuxPerfConfiguration; 41 view({attrs}: m.CVnode<RecordingSectionAttrs>) { 42 return m( 43 `.record-section${attrs.cssClass}`, 44 m( 45 Probe, 46 { 47 title: 'Callstack sampling', 48 img: 'rec_profiling.png', 49 descr: `Periodically records the current callstack (chain of 50 function calls) of processes.`, 51 setEnabled: (cfg, val) => (cfg.tracePerf = val), 52 isEnabled: (cfg) => cfg.tracePerf, 53 } as ProbeAttrs, 54 m(Slider, { 55 title: 'Sampling Frequency', 56 cssClass: '.thin', 57 values: [20, 40, 60, 80, 100, 120, 140, 160, 180, 200], 58 unit: 'hz', 59 set: (cfg, val) => (cfg.timebaseFrequency = val), 60 get: (cfg) => cfg.timebaseFrequency, 61 } as SliderAttrs), 62 m(Textarea, { 63 placeholder: PLACEHOLDER_TEXT, 64 cssClass: '.record-apps-list', 65 set: (cfg, val) => { 66 cfg.targetCmdLine = val.split('\n'); 67 }, 68 get: (cfg) => cfg.targetCmdLine.join('\n'), 69 } as TextareaAttrs), 70 ), 71 ); 72 } 73} 74