• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_ex.h"
17 #include "hidump_plugin_result.pbreader.h"
18 #include "htrace_event_parser.h"
19 #include "process_filter.h"
20 #include "stat_filter.h"
21 namespace SysTuning {
22 namespace TraceStreamer {
HtraceHidumpParser(TraceDataCache * dataCache,const TraceStreamerFilters * ctx)23 HtraceHidumpParser::HtraceHidumpParser(TraceDataCache* dataCache, const TraceStreamerFilters* ctx)
24     : EventParserBase(dataCache, ctx), clockId_(0)
25 {
26 }
27 
~HtraceHidumpParser()28 HtraceHidumpParser::~HtraceHidumpParser()
29 {
30     TS_LOGI("Fps data ts MIN:%llu, MAX:%llu", static_cast<unsigned long long>(GetPluginStartTime()),
31             static_cast<unsigned long long>(GetPluginEndTime()));
32 }
Parse(ProtoReader::BytesView tracePacket)33 void HtraceHidumpParser::Parse(ProtoReader::BytesView tracePacket)
34 {
35     ProtoReader::HidumpInfo_Reader hidumpInfo(tracePacket.data_, tracePacket.size_);
36     if (!hidumpInfo.has_fps_event()) {
37         return;
38     }
39     for (auto i = hidumpInfo.fps_event(); i; ++i) {
40         streamFilters_->statFilter_->IncreaseStat(TRACE_HIDUMP_FPS, STAT_EVENT_RECEIVED);
41         ProtoReader::FpsData_Reader hidumpData(i->ToBytes());
42         auto hidumpTime = ProtoReader::FpsData_TimeSpec_Reader(hidumpData.time());
43         auto timeStamp = hidumpTime.tv_nsec() + hidumpTime.tv_sec() * SEC_TO_NS;
44         auto newTimeStamp = streamFilters_->clockFilter_->ToPrimaryTraceTime(hidumpData.id(), timeStamp);
45         UpdatePluginTimeRange(hidumpData.id(), timeStamp, newTimeStamp);
46         clockId_ = hidumpData.id();
47         auto fps = hidumpData.fps();
48         traceDataCache_->GetHidumpData()->AppendNewHidumpInfo(newTimeStamp, fps);
49     }
50 }
Finish()51 void HtraceHidumpParser::Finish()
52 {
53     traceDataCache_->MixTraceTime(GetPluginStartTime(), GetPluginEndTime());
54 }
55 } // namespace TraceStreamer
56 } // namespace SysTuning
57