1 /*
2 * Copyright (c) 2021 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 #include "htrace_hidump_parser.h"
16 #include "clock_filter.h"
17 #include "htrace_event_parser.h"
18 #include "process_filter.h"
19 #include "stat_filter.h"
20 namespace SysTuning {
21 namespace TraceStreamer {
HtraceHidumpParser(TraceDataCache * dataCache,const TraceStreamerFilters * ctx)22 HtraceHidumpParser::HtraceHidumpParser(TraceDataCache* dataCache, const TraceStreamerFilters* ctx)
23 : HtracePluginTimeParser(dataCache, ctx) {}
24
~HtraceHidumpParser()25 HtraceHidumpParser::~HtraceHidumpParser()
26 {
27 TS_LOGI("Fps data ts MIN:%llu, MAX:%llu", static_cast<unsigned long long>(GetPluginStartTime()),
28 static_cast<unsigned long long>(GetPluginEndTime()));
29 }
Parse(HidumpInfo & tracePacket)30 void HtraceHidumpParser::Parse(HidumpInfo& tracePacket)
31 {
32 if (!tracePacket.fps_event_size()) {
33 return;
34 }
35 for (int i = 0; i < tracePacket.fps_event_size(); i++) {
36 streamFilters_->statFilter_->IncreaseStat(TRACE_HIDUMP_FPS, STAT_EVENT_RECEIVED);
37 auto hidumpData = tracePacket.mutable_fps_event(i);
38 auto timeStamp = hidumpData->time().tv_nsec() + hidumpData->time().tv_sec() * SEC_TO_NS;
39 auto newTimeStamp = streamFilters_->clockFilter_->ToPrimaryTraceTime(hidumpData->id(), timeStamp);
40 UpdatePluginTimeRange(hidumpData->id(), timeStamp, newTimeStamp);
41 clockId_ = hidumpData->id();
42 auto fps = hidumpData->fps();
43 traceDataCache_->GetHidumpData()->AppendNewHidumpInfo(newTimeStamp, fps);
44 }
45 }
Finish()46 void HtraceHidumpParser::Finish()
47 {
48 traceDataCache_->MixTraceTime(GetPluginStartTime(), GetPluginEndTime());
49 }
50 } // namespace TraceStreamer
51 } // namespace SysTuning
52