11e934351Sopenharmony_ci/*
21e934351Sopenharmony_ci * Copyright (c) 2023 Huawei Device Co., Ltd.
31e934351Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
41e934351Sopenharmony_ci * you may not use this file except in compliance with the License.
51e934351Sopenharmony_ci * You may obtain a copy of the License at
61e934351Sopenharmony_ci *
71e934351Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
81e934351Sopenharmony_ci *
91e934351Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
101e934351Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
111e934351Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
121e934351Sopenharmony_ci * See the License for the specific language governing permissions and
131e934351Sopenharmony_ci * limitations under the License.
141e934351Sopenharmony_ci */
151e934351Sopenharmony_ci#ifndef COMMUNICATIONNETSTACK_NETSTACK_TIMIMG_H
161e934351Sopenharmony_ci#define COMMUNICATIONNETSTACK_NETSTACK_TIMIMG_H
171e934351Sopenharmony_ci
181e934351Sopenharmony_ci#include <map>
191e934351Sopenharmony_ci#include <ctime>
201e934351Sopenharmony_ci
211e934351Sopenharmony_cinamespace OHOS::NetStack::Timing {
221e934351Sopenharmony_ci
231e934351Sopenharmony_ciclass Timer {
241e934351Sopenharmony_cipublic:
251e934351Sopenharmony_ci    const char* timerName_ = nullptr;
261e934351Sopenharmony_ci    Timer();
271e934351Sopenharmony_ci    void Start(time_t time);
281e934351Sopenharmony_ci    void Start();
291e934351Sopenharmony_ci    void Stop();
301e934351Sopenharmony_ci    double Elapsed() const;
311e934351Sopenharmony_ci
321e934351Sopenharmony_ciprivate:
331e934351Sopenharmony_ci    time_t startTime_ = 0;
341e934351Sopenharmony_ci    time_t endTime_ = 0;
351e934351Sopenharmony_ci};
361e934351Sopenharmony_ci
371e934351Sopenharmony_ciclass TimerMap {
381e934351Sopenharmony_cipublic:
391e934351Sopenharmony_ci    Timer& RecieveTimer(const char *const type);
401e934351Sopenharmony_ci
411e934351Sopenharmony_ciprivate:
421e934351Sopenharmony_ci    std::map<const char *const, Timer> timerMap_;
431e934351Sopenharmony_ci};
441e934351Sopenharmony_ci
451e934351Sopenharmony_ciclass TimeUtils {
461e934351Sopenharmony_cipublic:
471e934351Sopenharmony_ci    static time_t GetNowTimeMicroseconds();
481e934351Sopenharmony_ci
491e934351Sopenharmony_ci    static double Microseconds2Milliseconds(time_t microseconds);
501e934351Sopenharmony_ci};
511e934351Sopenharmony_ci} // namespace OHOS::NetStack::Timing
521e934351Sopenharmony_ci#endif /* COMMUNICATIONNETSTACK_NETSTACK_TIMING_H */