• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Copyright (C) 2019 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
15export type Column = (
16  | StringColumn
17  | TimestampColumn
18  | NumberColumn
19  | StateColumn
20) & {title: string; columnId: string};
21
22export interface StringColumn {
23  kind: 'STRING';
24  data: Uint16Array;
25}
26
27export interface TimestampColumn {
28  kind: 'TIMESTAMP_NS';
29  data: Float64Array;
30}
31
32export interface NumberColumn {
33  kind: 'NUMBER';
34  data: Uint16Array;
35}
36
37export interface StateColumn {
38  kind: 'STATE';
39  data: Uint16Array;
40}
41
42type TypedArrayConstructor =
43  | Uint16ArrayConstructor
44  | Float64ArrayConstructor
45  | Uint32ArrayConstructor;
46export interface ColumnDef {
47  title: string;
48  kind: string;
49  sum?: boolean;
50  columnConstructor: TypedArrayConstructor;
51  columnId: string;
52}
53
54export interface AggregateData {
55  tabName: string;
56  columns: Column[];
57  columnSums: string[];
58  // For string interning.
59  strings: string[];
60  // Some aggregations will have extra info to display;
61  extra?: ThreadStateExtra;
62}
63
64export function isEmptyData(data: AggregateData) {
65  return data.columns.length === 0 || data.columns[0].data.length === 0;
66}
67
68export interface ThreadStateExtra {
69  kind: 'THREAD_STATE';
70  states: string[];
71  values: Float64Array;
72  totalMs: number;
73}
74