blob: aa554cd65664f9976281ce8cf27ca510b8a9cadb [file] [log] [blame]
John Reckba6adf62015-02-19 14:36:50 -08001/*
2 * Copyright (C) 2015 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#ifndef JANKTRACKER_H_
17#define JANKTRACKER_H_
18
19#include "FrameInfo.h"
20#include "renderthread/TimeLord.h"
21#include "utils/RingBuffer.h"
22
23#include <memory>
24
25namespace android {
26namespace uirenderer {
27
28enum JankType {
29 kMissedVsync = 0,
30 kHighInputLatency,
31 kSlowUI,
32 kSlowSync,
33 kSlowRT,
34
35 // must be last
36 NUM_BUCKETS,
37};
38
39struct JankBucket {
40 // Number of frames that hit this bucket
41 uint32_t count;
42};
43
44// TODO: Replace DrawProfiler with this
45class JankTracker {
46public:
47 JankTracker(nsecs_t frameIntervalNanos);
48
49 void setFrameInterval(nsecs_t frameIntervalNanos);
50
51 void addFrame(const FrameInfo& frame);
52
53 void dump(int fd);
54 void reset();
55
56private:
57 JankBucket mBuckets[NUM_BUCKETS];
58 int64_t mThresholds[NUM_BUCKETS];
59
60 int64_t mFrameInterval;
61 uint32_t mTotalFrameCount;
62 uint32_t mJankFrameCount;
63};
64
65} /* namespace uirenderer */
66} /* namespace android */
67
68#endif /* JANKTRACKER_H_ */