1 /* 2 * Copyright (C) 2011 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.frameworkperf; 18 19 import android.os.Parcel; 20 import android.os.Parcelable; 21 22 public class RunResult implements Parcelable { 23 final String name; 24 final String fgLongName; 25 final String bgLongName; 26 final long fgTime; 27 final long fgOps; 28 final long bgTime; 29 final long bgOps; 30 RunResult(TestService.TestRunner op)31 RunResult(TestService.TestRunner op) { 32 name = op.getName(); 33 fgLongName = op.getForegroundLongName(); 34 bgLongName = op.getBackgroundLongName(); 35 fgTime = op.getForegroundTime(); 36 fgOps = op.getForegroundOps(); 37 bgTime = op.getBackgroundTime(); 38 bgOps = op.getBackgroundOps(); 39 } 40 RunResult(Parcel source)41 RunResult(Parcel source) { 42 name = source.readString(); 43 fgLongName = source.readString(); 44 bgLongName = source.readString(); 45 fgTime = source.readLong(); 46 fgOps = source.readLong(); 47 bgTime = source.readLong(); 48 bgOps = source.readLong(); 49 } 50 getFgMsPerOp()51 float getFgMsPerOp() { 52 return fgOps != 0 ? (fgTime / (float)fgOps) : 0; 53 } 54 getBgMsPerOp()55 float getBgMsPerOp() { 56 return bgOps != 0 ? (bgTime / (float)bgOps) : 0; 57 } 58 59 @Override describeContents()60 public int describeContents() { 61 return 0; 62 } 63 64 @Override writeToParcel(Parcel dest, int flags)65 public void writeToParcel(Parcel dest, int flags) { 66 dest.writeString(name); 67 dest.writeString(fgLongName); 68 dest.writeString(bgLongName); 69 dest.writeLong(fgTime); 70 dest.writeLong(fgOps); 71 dest.writeLong(bgTime); 72 dest.writeLong(bgOps); 73 } 74 75 public static final Parcelable.Creator<RunResult> CREATOR 76 = new Parcelable.Creator<RunResult>() { 77 public RunResult createFromParcel(Parcel in) { 78 return new RunResult(in); 79 } 80 81 public RunResult[] newArray(int size) { 82 return new RunResult[size]; 83 } 84 }; 85 }