1bc03f14fSopenharmony_ci/*
2bc03f14fSopenharmony_ci * Copyright (c) 2022-2023 Huawei Device Co., Ltd.
3bc03f14fSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4bc03f14fSopenharmony_ci * you may not use this file except in compliance with the License.
5bc03f14fSopenharmony_ci * You may obtain a copy of the License at
6bc03f14fSopenharmony_ci *
7bc03f14fSopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
8bc03f14fSopenharmony_ci *
9bc03f14fSopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10bc03f14fSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11bc03f14fSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12bc03f14fSopenharmony_ci * See the License for the specific language governing permissions and
13bc03f14fSopenharmony_ci * limitations under the License.
14bc03f14fSopenharmony_ci */
15bc03f14fSopenharmony_ci
16bc03f14fSopenharmony_ci#ifndef TIME_CONSUMING_H
17bc03f14fSopenharmony_ci#define TIME_CONSUMING_H
18bc03f14fSopenharmony_ci
19bc03f14fSopenharmony_ci#include <cstdint>
20bc03f14fSopenharmony_ci#include <ctime>
21bc03f14fSopenharmony_ci
22bc03f14fSopenharmony_ci#include "singleton.h"
23bc03f14fSopenharmony_ci
24bc03f14fSopenharmony_cinamespace OHOS {
25bc03f14fSopenharmony_cinamespace MiscServices {
26bc03f14fSopenharmony_cienum class TimeLevel : std::uint64_t {
27bc03f14fSopenharmony_ci    PER_FIVE_HUNDRED_MS_ZERO = 0,
28bc03f14fSopenharmony_ci    PER_FIVE_HUNDRED_MS_ONE,
29bc03f14fSopenharmony_ci    PER_FIVE_HUNDRED_MS_TWO,
30bc03f14fSopenharmony_ci    PER_FIVE_HUNDRED_MS_THREE,
31bc03f14fSopenharmony_ci    PER_FIVE_HUNDRED_MS_FOUR,
32bc03f14fSopenharmony_ci    PER_FIVE_HUNDRED_MS_FIVE,
33bc03f14fSopenharmony_ci    PER_FIVE_HUNDRED_MS_SIX,
34bc03f14fSopenharmony_ci    PER_FIVE_HUNDRED_MS_SEVEN,
35bc03f14fSopenharmony_ci    PER_FIVE_HUNDRED_MS_EIGHT,
36bc03f14fSopenharmony_ci    PER_FIVE_HUNDRED_MS_NINE,
37bc03f14fSopenharmony_ci};
38bc03f14fSopenharmony_ci
39bc03f14fSopenharmony_ciclass CalculateTimeConsuming : public Singleton<CalculateTimeConsuming> {
40bc03f14fSopenharmony_cipublic:
41bc03f14fSopenharmony_ci    CalculateTimeConsuming(const size_t calPasteboardData, const int calPasteboardState);
42bc03f14fSopenharmony_ci    ~CalculateTimeConsuming();
43bc03f14fSopenharmony_ci    static void SetBeginTime();
44bc03f14fSopenharmony_ci
45bc03f14fSopenharmony_ciprivate:
46bc03f14fSopenharmony_ci    static uint64_t GetCurrentTimeMicros();
47bc03f14fSopenharmony_ci    int CalculateTime(uint64_t time);
48bc03f14fSopenharmony_ci    int CalculateData(size_t calPasteboardData) const;
49bc03f14fSopenharmony_ci
50bc03f14fSopenharmony_ci    int pasteboardData_;
51bc03f14fSopenharmony_ci    int pasteboardState_;
52bc03f14fSopenharmony_ci    static uint64_t lastTime_;
53bc03f14fSopenharmony_ci};
54bc03f14fSopenharmony_ci} // namespace MiscServices
55bc03f14fSopenharmony_ci} // namespace OHOS
56bc03f14fSopenharmony_ci#endif // TIME_CONSUMING_H
57