Shuzhen Wang | 686f644 | 2017-06-20 16:16:04 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2017 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 | #ifndef ANDROID_SERVERS_CAMERA_LATENCY_HISTOGRAM_H_ |
| 18 | #define ANDROID_SERVERS_CAMERA_LATENCY_HISTOGRAM_H_ |
| 19 | |
| 20 | #include <vector> |
| 21 | |
| 22 | #include <utils/Timers.h> |
| 23 | #include <utils/Mutex.h> |
| 24 | |
| 25 | namespace android { |
| 26 | |
| 27 | // Histogram for camera latency characteristic |
| 28 | class CameraLatencyHistogram { |
| 29 | public: |
| 30 | CameraLatencyHistogram() = delete; |
| 31 | CameraLatencyHistogram(int32_t binSizeMs, int32_t binCount=10); |
| 32 | void add(nsecs_t start, nsecs_t end); |
| 33 | void reset(); |
| 34 | |
| 35 | void dump(int fd, const char* name) const; |
| 36 | void log(const char* format, ...); |
| 37 | private: |
| 38 | int32_t mBinSizeMs; |
| 39 | int32_t mBinCount; |
| 40 | std::vector<int64_t> mBins; |
| 41 | uint64_t mTotalCount; |
| 42 | |
| 43 | void formatHistogramText(String8& lineBins, String8& lineBinCounts) const; |
| 44 | }; // class CameraLatencyHistogram |
| 45 | |
| 46 | }; // namespace android |
| 47 | |
| 48 | #endif // ANDROID_SERVERS_CAMERA_LATENCY_HISTOGRAM_H_ |