1/* 2 * Copyright (c) 2021 Huawei Device Co., Ltd. 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 */ 15 select 16 itid as tid, 17 ipid as pid, 18 group_concat(cpu,",") as cpu, 19 group_concat(duration,",") as duration, 20 group_concat(min_freq,",") as min_freq, 21 group_concat(max_freq,",") as max_freq, 22 group_concat(avg_frequency,",") as avg_frequency, 23 process_name, 24 thread_name 25 from 26 ( 27 SELECT itid, 28 ipid, 29 cpu, 30 CAST(SUM(duration) AS INT) AS duration, 31 CAST(MIN(freq) AS INT) AS min_freq, 32 CAST(MAX(freq) AS INT) AS max_freq, 33 CAST((SUM(duration * freq) / SUM(duration)) AS INT) AS avg_frequency, 34 process_name, 35 thread_name 36 FROM (SELECT (MIN(cpu_frequency_view.end_ts, cpu_thread_view.end_ts) - MAX(cpu_frequency_view.start_ts, cpu_thread_view.ts)) AS duration, 37 freq, 38 cpu_thread_view.cpu as cpu, 39 itid, 40 ipid, 41 process_name, 42 thread_name 43 FROM cpu_frequency_view JOIN cpu_thread_view ON(cpu_frequency_view.cpu = cpu_thread_view.cpu) 44 WHERE cpu_frequency_view.start_ts < cpu_thread_view.end_ts AND cpu_frequency_view.end_ts > cpu_thread_view.ts 45 ) GROUP BY itid, cpu 46 ) 47GROUP BY ipid, itid order by ipid