1 /* 2 * Copyright (c) 2021 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef FOUNDATION_ACE_FRAMEWORKS_BASE_LOG_ACE_TRACKER_H 17 #define FOUNDATION_ACE_FRAMEWORKS_BASE_LOG_ACE_TRACKER_H 18 19 #include <cstdarg> 20 #include <cstdint> 21 #include <cstdio> 22 #include <string> 23 24 #include "base/json/json_util.h" 25 #include "base/utils/macros.h" 26 #include "base/utils/noncopyable.h" 27 28 #define ACE_FUNCTION_TRACK() AceScopedTracker aceScopedTracker(__func__) 29 30 namespace OHOS::Ace { 31 32 class ACE_EXPORT AceTracker final { 33 public: 34 static void Start(); 35 36 static std::string Stop(); 37 38 private: 39 AceTracker() = default; 40 ~AceTracker() = default; 41 42 static std::unique_ptr<JsonValue> trackInfo_; 43 44 friend class AceScopedTracker; 45 ACE_DISALLOW_COPY_AND_MOVE(AceTracker); 46 }; 47 48 class ACE_EXPORT AceScopedTracker final { 49 public: 50 explicit AceScopedTracker(const std::string& tag); 51 ~AceScopedTracker(); 52 53 private: 54 std::string tag_; 55 // micro sec 56 int64_t markTime_ = 0; 57 58 ACE_DISALLOW_COPY_AND_MOVE(AceScopedTracker); 59 }; 60 61 } // namespace OHOS::Ace 62 63 #endif // FOUNDATION_ACE_FRAMEWORKS_BASE_LOG_ACE_TRACKER_H 64