• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Copyright (c) 2021 Huawei Device Co., Ltd.
2// Licensed under the Apache License, Version 2.0 (the "License");
3// you may not use this file except in compliance with the License.
4// You may obtain a copy of the License at
5//
6//     http://www.apache.org/licenses/LICENSE-2.0
7//
8// Unless required by applicable law or agreed to in writing, software
9// distributed under the License is distributed on an "AS IS" BASIS,
10// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11// See the License for the specific language governing permissions and
12// limitations under the License.
13
14import { QueryEnum, TraficEnum } from './utils/QueryEnum';
15import { threadPool } from '../SqlLite';
16import { TraceRow } from '../../component/trace/base/TraceRow';
17
18export function sliceSender(): Promise<unknown> {
19  let trafic: number = TraficEnum.Memory;
20  return new Promise((resolve): void => {
21    threadPool.submitProto(
22      QueryEnum.SliceData,
23      {
24        trafic: trafic,
25        startNS: TraceRow.range?.startNS || 0,
26        endNS: TraceRow.range?.endNS || 0,
27        recordStartNS: window.recordStartNS,
28        recordEndNS: window.recordEndNS,
29      },
30      (res: unknown): void => {
31        resolve(res);
32      }
33    );
34  });
35}
36
37export function sliceSPTSender(leftNs: number, rightNs: number, cpus: Array<number>, func: string): Promise<unknown[]> {
38  return new Promise((resolve): void => {
39    threadPool.submitProto(
40      QueryEnum.SliceSPTData,
41      {
42        leftNs: leftNs,
43        rightNs: rightNs,
44        cpus: cpus,
45        func: func,
46        trafic: TraficEnum.Memory,
47      },
48      (res: unknown, len: number, transfer: boolean): void => {
49        //@ts-ignore
50        resolve(res);
51      }
52    );
53  });
54}
55