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 interface TimeBase { 20 public static final TimeBase CPU_TIME = new CpuTimeBase(); 21 public static final TimeBase REAL_TIME = new RealTimeBase(); 22 getTime(ThreadData threadData)23 public long getTime(ThreadData threadData); getElapsedInclusiveTime(MethodData methodData)24 public long getElapsedInclusiveTime(MethodData methodData); getElapsedExclusiveTime(MethodData methodData)25 public long getElapsedExclusiveTime(MethodData methodData); getElapsedInclusiveTime(ProfileData profileData)26 public long getElapsedInclusiveTime(ProfileData profileData); 27 28 public static final class CpuTimeBase implements TimeBase { 29 @Override getTime(ThreadData threadData)30 public long getTime(ThreadData threadData) { 31 return threadData.getCpuTime(); 32 } 33 34 @Override getElapsedInclusiveTime(MethodData methodData)35 public long getElapsedInclusiveTime(MethodData methodData) { 36 return methodData.getElapsedInclusiveCpuTime(); 37 } 38 39 @Override getElapsedExclusiveTime(MethodData methodData)40 public long getElapsedExclusiveTime(MethodData methodData) { 41 return methodData.getElapsedExclusiveCpuTime(); 42 } 43 44 @Override getElapsedInclusiveTime(ProfileData profileData)45 public long getElapsedInclusiveTime(ProfileData profileData) { 46 return profileData.getElapsedInclusiveCpuTime(); 47 } 48 } 49 50 public static final class RealTimeBase implements TimeBase { 51 @Override getTime(ThreadData threadData)52 public long getTime(ThreadData threadData) { 53 return threadData.getRealTime(); 54 } 55 56 @Override getElapsedInclusiveTime(MethodData methodData)57 public long getElapsedInclusiveTime(MethodData methodData) { 58 return methodData.getElapsedInclusiveRealTime(); 59 } 60 61 @Override getElapsedExclusiveTime(MethodData methodData)62 public long getElapsedExclusiveTime(MethodData methodData) { 63 return methodData.getElapsedExclusiveRealTime(); 64 } 65 66 @Override getElapsedInclusiveTime(ProfileData profileData)67 public long getElapsedInclusiveTime(ProfileData profileData) { 68 return profileData.getElapsedInclusiveRealTime(); 69 } 70 } 71 } 72