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
18package android.filterpacks.performance;
19
20/**
21 * @hide
22 */
23public class Throughput {
24
25    private final int mTotalFrames;
26    private final int mPeriodFrames;
27    private final int mPeriodTime;
28    private final int mPixels;
29
30    public Throughput(int totalFrames, int periodFrames, int periodTime, int pixels) {
31        mTotalFrames = totalFrames;
32        mPeriodFrames = periodFrames;
33        mPeriodTime = periodTime;
34        mPixels = pixels;
35    }
36
37    public int getTotalFrameCount() {
38        return mTotalFrames;
39    }
40
41    public int getPeriodFrameCount() {
42        return mPeriodFrames;
43    }
44
45    public int getPeriodTime() {
46        return mPeriodTime;
47    }
48
49    public float getFramesPerSecond() {
50        return mPeriodFrames / (float)mPeriodTime;
51    }
52
53    public float getNanosPerPixel() {
54        double frameTimeInNanos = (mPeriodTime / (double)mPeriodFrames) * 1000000.0;
55        return (float)(frameTimeInNanos / mPixels);
56    }
57
58    public String toString() {
59        return getFramesPerSecond() + " FPS";
60    }
61}
62