1/* 2 * Copyright (C) 2022 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// VM Tracker Dma泳道图 16import { Dma, DmaComparison } from '../../bean/AbilityMonitor'; 17import { query } from '../SqlLite'; 18import { SnapshotStruct } from '../ui-worker/ProcedureWorkerSnapshot'; 19 20export const queryDmaSampsData = (process: number): Promise<Array<SnapshotStruct>> => 21 query( 22 'queryDmaSampsData', 23 `SELECT 24 (A.ts - B.start_ts) as startNs, 25 sum(A.size) as value, 26 A.flag as flag, 27 A.ipid as ipid, 28 E.data as expTaskComm 29 FROM memory_dma A,trace_range B 30 left join data_dict as E on E.id=A.exp_task_comm_id 31 WHERE 32 A.flag = 0 33 AND $pid = A.ipid 34 AND A.ts < B.end_ts 35 GROUP by A.ts;`, 36 { $pid: process } 37 ); 38 39export const queryisExistsDmaData = (process: number): Promise<Array<SnapshotStruct>> => 40 query( 41 'queryisExistsDmaData', 42 `SELECT EXISTS ( 43 SELECT 1 44 FROM memory_dma A,trace_range B 45 left join data_dict as E on E.id=A.exp_task_comm_id 46 WHERE A.flag = 0 47 AND $pid = A.ipid 48 AND A.ts < B.end_ts 49 GROUP by A.ts 50 ) AS data_exists`, 51 { $pid: process } 52 ); 53 54//Ability Monitor Dma 框选 55export const getTabDmaAbilityData = (leftNs: number, rightNs: number, dur: number): Promise<Array<Dma>> => 56 query<Dma>( 57 'getTabDmaAbilityData', 58 `SELECT (S.ts-TR.start_ts) as startNs, 59 MAX(S.size) as maxSize, 60 MIN(S.size) as minSize, 61 Avg(S.size) as avgSize, 62 E.pid as processId, 63 E.name as processName 64 from trace_range as TR,memory_dma as S 65 left join process as E on E.ipid=S.ipid 66 WHERE 67 $leftNS <= startNs + ${dur} and $rightNS >= startNs 68 and flag = 0 69 GROUP by E.pid 70 `, 71 { $leftNS: leftNs, $rightNS: rightNs } 72 ); 73 74//VM Tracker Dma 框选 75export const getTabDmaVmTrackerData = ( 76 leftNs: number, 77 rightNs: number, 78 processId: number, 79 dur: number 80): Promise<Array<Dma>> => 81 query<Dma>( 82 'getTabDmaVmTrackerData', 83 `SELECT (S.ts-TR.start_ts) as startNs, 84 MAX(S.size) as maxSize, 85 MIN(S.size) as minSize, 86 Avg(S.size) as avgSize 87 from trace_range as TR,memory_dma as S 88 left join data_dict as C on C.id=S.exp_task_comm_id 89 where 90 $leftNS <= startNs + ${dur} and $rightNS >= startNs 91 and flag = 0 92 and 93 $pid = S.ipid 94 `, 95 { $leftNS: leftNs, $rightNS: rightNs, $pid: processId } 96 ); 97 98//Ability Monitor Dma 点选 99export const getTabDmaAbilityClickData = (startNs: number): Promise<Array<Dma>> => 100 query<Dma>( 101 'getTabDmaAbilityClickData', 102 `SELECT 103 (S.ts-TR.start_ts) as startNs, 104 S.fd as fd, 105 S.size as size, 106 S.ino as ino, 107 S.exp_pid as expPid, 108 buf_name_id as bufName, 109 exp_name_id as expName, 110 exp_task_comm_id as expTaskComm, 111 E.pid as processId, 112 E.name as processName, 113 S.flag as flag 114 from trace_range as TR,memory_dma as S 115 left join process as E on E.ipid=S.ipid 116 WHERE 117 startNs = ${startNs} 118 `, 119 { $startNs: startNs } 120 ); 121 122//VM Tracker Dma 点选 123export const getTabDmaVMTrackerClickData = (startNs: number, processId: number): Promise<Array<Dma>> => 124 query<Dma>( 125 'getTabDmaVMTrackerClickData', 126 `SELECT 127 (S.ts-TR.start_ts) as startNs, 128 S.fd as fd, 129 S.size as size, 130 S.ino as ino, 131 S.exp_pid as expPid, 132 buf_name_id as bufName, 133 exp_name_id as expName, 134 exp_task_comm_id as expTaskComm, 135 S.flag as flag 136 from trace_range as TR,memory_dma as S 137 WHERE 138 startNs = ${startNs} 139 AND 140 $pid = S.ipid 141 `, 142 { $startNs: startNs, $pid: processId } 143 ); 144 145//Ability Monitor Dma 点选比较 146export const getTabDmaAbilityComparisonData = (startNs: number): Promise<Array<DmaComparison>> => 147 query<DmaComparison>( 148 'getTabDmaAbilityComparisonData', 149 `SELECT 150 (S.ts-TR.start_ts) as startNs, 151 sum(S.size) as value, 152 E.pid as processId, 153 E.name as processName 154 from trace_range as TR,memory_dma as S 155 left join process as E on E.ipid=S.ipid 156 WHERE 157 startNs = ${startNs} 158 GROUP by 159 E.pid 160 `, 161 { $startNs: startNs } 162 ); 163 164//VM Tracker Dma 点选比较 165export const getTabDmaVmTrackerComparisonData = (startNs: number, processId: number): Promise<Array<DmaComparison>> => 166 query<DmaComparison>( 167 'getTabDmaVmTrackerComparisonData', 168 `SELECT 169 (S.ts-TR.start_ts) as startNs, 170 sum(S.size) as value 171 from trace_range as TR,memory_dma as S 172 WHERE 173 startNs = ${startNs} 174 AND 175 $pid = S.ipid 176 `, 177 { $startNs: startNs, $pid: processId } 178 ); 179