• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "singleton.h"
20 
21 namespace OHOS {
22 namespace MiscServices {
23 enum class TimeLevel : std::uint32_t {
24     PER_FIVE_HUNDRED_MS_ZERO = 0,
25     PER_FIVE_HUNDRED_MS_ONE,
26     PER_FIVE_HUNDRED_MS_TWO,
27     PER_FIVE_HUNDRED_MS_THREE,
28     PER_FIVE_HUNDRED_MS_FOUR,
29     PER_FIVE_HUNDRED_MS_FIVE,
30     PER_FIVE_HUNDRED_MS_SIX,
31     PER_FIVE_HUNDRED_MS_SEVEN,
32     PER_FIVE_HUNDRED_MS_EIGHT,
33     PER_FIVE_HUNDRED_MS_NINE,
34 };
35 
36 class CalculateTimeConsuming : public Singleton<CalculateTimeConsuming> {
37 public:
38     CalculateTimeConsuming(const size_t calPasteboardData, const int calPasteboardState);
39     ~CalculateTimeConsuming();
40     static void SetBeginTime();
41 
42 private:
43     static uint64_t GetCurrentTimeMicros();
44     int CalculateTime(uint64_t time);
45     int CalculateData(size_t calPasteboardData) const;
46 
47     int pasteboardData_;
48     int pasteboardState_;
49     static uint64_t lastTime_;
50 };
51 } // namespace MiscServices
52 } // namespace OHOS
53 #endif // TIME_CONSUMING_H
54