1 /* 2 * Copyright (c) 2022-2023 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 TIME_CONSUMING_H 17 #define TIME_CONSUMING_H 18 19 #include <cstdint> 20 #include <ctime> 21 22 #include "singleton.h" 23 24 namespace OHOS { 25 namespace MiscServices { 26 enum class TimeLevel : std::uint64_t { 27 PER_FIVE_HUNDRED_MS_ZERO = 0, 28 PER_FIVE_HUNDRED_MS_ONE, 29 PER_FIVE_HUNDRED_MS_TWO, 30 PER_FIVE_HUNDRED_MS_THREE, 31 PER_FIVE_HUNDRED_MS_FOUR, 32 PER_FIVE_HUNDRED_MS_FIVE, 33 PER_FIVE_HUNDRED_MS_SIX, 34 PER_FIVE_HUNDRED_MS_SEVEN, 35 PER_FIVE_HUNDRED_MS_EIGHT, 36 PER_FIVE_HUNDRED_MS_NINE, 37 }; 38 39 class CalculateTimeConsuming : public Singleton<CalculateTimeConsuming> { 40 public: 41 CalculateTimeConsuming(const size_t calPasteboardData, const int calPasteboardState); 42 ~CalculateTimeConsuming(); 43 static void SetBeginTime(); 44 45 private: 46 static uint64_t GetCurrentTimeMicros(); 47 int CalculateTime(uint64_t time); 48 int CalculateData(size_t calPasteboardData) const; 49 50 int pasteboardData_; 51 int pasteboardState_; 52 static uint64_t lastTime_; 53 }; 54 } // namespace MiscServices 55 } // namespace OHOS 56 #endif // TIME_CONSUMING_H 57