• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2006 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.android.traceview;
18 
19 
20 public class ProfileData {
21 
22     protected MethodData mElement;
23 
24     /** mContext is either the parent or child of mElement */
25     protected MethodData mContext;
26     protected boolean mElementIsParent;
27     protected long mElapsedInclusive;
28     protected int mNumCalls;
29 
ProfileData()30     public ProfileData() {
31     }
32 
ProfileData(MethodData context, MethodData element, boolean elementIsParent)33     public ProfileData(MethodData context, MethodData element,
34             boolean elementIsParent) {
35         mContext = context;
36         mElement = element;
37         mElementIsParent = elementIsParent;
38     }
39 
getProfileName()40     public String getProfileName() {
41         return mElement.getProfileName();
42     }
43 
getMethodData()44     public MethodData getMethodData() {
45         return mElement;
46     }
47 
addElapsedInclusive(long elapsedInclusive)48     public void addElapsedInclusive(long elapsedInclusive) {
49         mElapsedInclusive += elapsedInclusive;
50         mNumCalls += 1;
51     }
52 
setElapsedInclusive(long elapsedInclusive)53     public void setElapsedInclusive(long elapsedInclusive) {
54         mElapsedInclusive = elapsedInclusive;
55     }
56 
getElapsedInclusive()57     public long getElapsedInclusive() {
58         return mElapsedInclusive;
59     }
60 
setNumCalls(int numCalls)61     public void setNumCalls(int numCalls) {
62         mNumCalls = numCalls;
63     }
64 
getNumCalls()65     public String getNumCalls() {
66         int totalCalls;
67         if (mElementIsParent)
68             totalCalls = mContext.getTotalCalls();
69         else
70             totalCalls = mElement.getTotalCalls();
71         return String.format("%d/%d", mNumCalls, totalCalls);
72     }
73 
isParent()74     public boolean isParent() {
75         return mElementIsParent;
76     }
77 
getContext()78     public MethodData getContext() {
79         return mContext;
80     }
81 }
82