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 BaseCounterTrack, 19 CounterOptions, 20} from '../../frontend/base_counter_track'; 21import {CloseTrackButton} from '../../frontend/close_track_button'; 22import {NewTrackArgs} from '../../frontend/track'; 23 24export class RunnableThreadCountTrack extends BaseCounterTrack { 25 static readonly kind = 'dev.perfetto.Sched.RunnableThreadCount'; 26 27 constructor(args: NewTrackArgs) { 28 super(args); 29 } 30 31 getTrackShellButtons(): m.Children { 32 return m(CloseTrackButton, { 33 trackKey: this.trackKey, 34 }); 35 } 36 37 protected getDefaultCounterOptions(): CounterOptions { 38 const options = super.getDefaultCounterOptions(); 39 options.yRangeRounding = 'strict'; 40 options.yRange = 'viewport'; 41 return options; 42 } 43 44 async onInit() { 45 await this.engine.query( 46 `INCLUDE PERFETTO MODULE sched.thread_level_parallelism`, 47 ); 48 } 49 50 getSqlSource() { 51 return ` 52 select 53 ts, 54 runnable_thread_count as value 55 from sched_runnable_thread_count 56 `; 57 } 58} 59