!1699 fix some bugs for heapstatsupdate event

Merge pull request !1699 from Riachel/master
This commit is contained in:
openharmony_ci 2022-06-30 11:55:08 +00:00 committed by Gitee
commit 0808ad92c9
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
3 changed files with 7 additions and 13 deletions

View File

@ -119,14 +119,7 @@ bool HeapSnapshot::FinishSnapshot()
void HeapSnapshot::RecordSampleTime()
{
uint32_t len = timeStamps_.size();
if (len > 0) {
if (sequenceId_ != timeStamps_[len - 1U].GetLastSequenceId()) {
timeStamps_.emplace_back(sequenceId_);
}
} else {
timeStamps_.emplace_back(sequenceId_);
}
timeStamps_.emplace_back(sequenceId_ + SEQ_STEP);
}
void HeapSnapshot::PushHeapStat(Stream* stream)
@ -166,7 +159,7 @@ void HeapSnapshot::PushHeapStat(Stream* stream)
stream->UpdateHeapStats(&statsBuffer.front(), static_cast<int32_t>(statsBuffer.size()));
statsBuffer.clear();
}
stream->UpdateLastSeenObjectId(sequenceId);
stream->UpdateLastSeenObjectId(sequenceId_);
}
void HeapSnapshot::AddNode(TaggedObject* address)

View File

@ -226,7 +226,8 @@ void HeapProfilerImpl::Frontend::LastSeenObjectId(int32_t lastSeenObjectId)
gettimeofday(&tv, nullptr);
const int THOUSAND = 1000;
timestamp = static_cast<int64_t>(tv.tv_usec + tv.tv_sec * THOUSAND * THOUSAND);
lastSeenObjectIdEvent.SetTimestamp(timestamp);
double timestampMS = static_cast<double>(timestamp) / THOUSAND;
lastSeenObjectIdEvent.SetTimestamp(timestampMS);
channel_->SendNotification(lastSeenObjectIdEvent);
}

View File

@ -992,12 +992,12 @@ public:
return *this;
}
int64_t GetTimestamp() const
double GetTimestamp() const
{
return timestamp_;
}
LastSeenObjectId &SetTimestamp(int64_t timestamp)
LastSeenObjectId &SetTimestamp(double timestamp)
{
timestamp_ = timestamp;
return *this;
@ -1008,7 +1008,7 @@ private:
NO_MOVE_SEMANTIC(LastSeenObjectId);
int32_t lastSeenObjectId_ {};
int64_t timestamp_ {};
double timestamp_ {};
};
class ReportHeapSnapshotProgress final : public PtBaseEvents {