Home | History | Annotate | Download | only in traceview
      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 
     30     public ProfileData() {
     31     }
     32 
     33     public ProfileData(MethodData context, MethodData element,
     34             boolean elementIsParent) {
     35         mContext = context;
     36         mElement = element;
     37         mElementIsParent = elementIsParent;
     38     }
     39 
     40     public String getProfileName() {
     41         return mElement.getProfileName();
     42     }
     43 
     44     public MethodData getMethodData() {
     45         return mElement;
     46     }
     47 
     48     public void addElapsedInclusive(long elapsedInclusive) {
     49         mElapsedInclusive += elapsedInclusive;
     50         mNumCalls += 1;
     51     }
     52 
     53     public void setElapsedInclusive(long elapsedInclusive) {
     54         mElapsedInclusive = elapsedInclusive;
     55     }
     56 
     57     public long getElapsedInclusive() {
     58         return mElapsedInclusive;
     59     }
     60 
     61     public void setNumCalls(int numCalls) {
     62         mNumCalls = numCalls;
     63     }
     64 
     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 
     74     public boolean isParent() {
     75         return mElementIsParent;
     76     }
     77 
     78     public MethodData getContext() {
     79         return mContext;
     80     }
     81 }
     82