Alex Ray | c16e56d | 2013-04-29 12:24:49 -0700 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (C) 2013 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 CAMERA_SCOPED_TRACE_H |
| 18 | #define CAMERA_SCOPED_TRACE_H |
| 19 | |
| 20 | #include <stdint.h> |
| 21 | #include <cutils/trace.h> |
| 22 | |
| 23 | // See <cutils/trace.h> for more tracing macros. |
| 24 | |
| 25 | // CAMTRACE_NAME traces the beginning and end of the current scope. To trace |
| 26 | // the correct start and end times this macro should be declared first in the |
| 27 | // scope body. |
| 28 | #define CAMTRACE_NAME(name) ScopedTrace ___tracer(ATRACE_TAG, name) |
| 29 | // CAMTRACE_CALL is an ATRACE_NAME that uses the current function name. |
| 30 | #define CAMTRACE_CALL() CAMTRACE_NAME(__FUNCTION__) |
| 31 | |
| 32 | namespace default_camera_hal { |
| 33 | |
| 34 | class ScopedTrace { |
| 35 | public: |
| 36 | inline ScopedTrace(uint64_t tag, const char* name) |
| 37 | : mTag(tag) { |
| 38 | atrace_begin(mTag,name); |
| 39 | } |
| 40 | |
| 41 | inline ~ScopedTrace() { |
| 42 | atrace_end(mTag); |
| 43 | } |
| 44 | |
| 45 | private: |
| 46 | uint64_t mTag; |
| 47 | }; |
| 48 | |
| 49 | }; // namespace default_camera_hal |
| 50 | |
| 51 | #endif // CAMERA_SCOPED_TRACE_H |