1 /* 2 * Copyright (c) 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 OHOS_TIME_STATISTICIAN_H 17 #define OHOS_TIME_STATISTICIAN_H 18 19 #include "ifeedable_data.h" 20 #include <memory> 21 namespace OHOS { 22 namespace DistributedHardware { 23 class TimeStatistician { 24 public: 25 virtual ~TimeStatistician() = default; 26 virtual void CalProcessTime(const std::shared_ptr<IFeedableData>& data); 27 void CalAverFeedInterval(const int64_t feedTime); 28 void CalAverTimeStampInterval(const int64_t timeStamp); 29 30 public: 31 int64_t GetAverFeedInterval(); 32 int64_t GetAverTimeStampInterval(); 33 int64_t GetFeedInterval(); 34 int64_t GetTimeStampInterval(); 35 36 public: 37 uint32_t feedIndex_ = 0; 38 int64_t averFeedInterval_ = 0; 39 int64_t lastFeedTime_ = 0; 40 int64_t feedTime_ = 0; 41 int64_t feedIntervalSum_ = 0; 42 int64_t feedInterval_ = 0; 43 44 uint32_t timeStampIndex_ = 0; 45 int64_t averTimeStampInterval_ = 0; 46 int64_t lastTimeStamp_ = 0; 47 int64_t timeStamp_ = 0; 48 int64_t timeStampIntervalSum_ = 0; 49 int64_t timeStampInterval_ = 0; 50 }; 51 } // namespace DistributedHardware 52 } // namespace OHOS 53 #endif // OHOS_TIME_STATISTICIAN_H