fix bug for lastobjectid

Signed-off-by: cwx1148594 <caolili14@huawei.com>
This commit is contained in:
cwx1148594 2023-02-28 17:22:53 +08:00
parent 0c385b18b3
commit c084996837
2 changed files with 5 additions and 9 deletions

View File

@ -230,7 +230,7 @@ void HeapProfilerImpl::Frontend::HeapStatsUpdate(HeapStat* updateData, int32_t c
channel_->SendNotification(heapStatsUpdate);
}
void HeapProfilerImpl::Frontend::LastSeenObjectId(int32_t lastSeenObjectId)
void HeapProfilerImpl::Frontend::LastSeenObjectId(int32_t lastSeenObjectId, int64_t timeStampUs)
{
if (!AllowNotify()) {
return;
@ -238,12 +238,8 @@ void HeapProfilerImpl::Frontend::LastSeenObjectId(int32_t lastSeenObjectId)
tooling::LastSeenObjectId lastSeenObjectIdEvent;
lastSeenObjectIdEvent.SetLastSeenObjectId(lastSeenObjectId);
int64_t timestamp = 0;
struct timeval tv = {0, 0};
gettimeofday(&tv, nullptr);
const int THOUSAND = 1000;
timestamp = static_cast<int64_t>(tv.tv_usec + tv.tv_sec * THOUSAND * THOUSAND);
double timestampMS = static_cast<double>(timestamp) / THOUSAND;
double timestampMS = static_cast<double>(timeStampUs) / THOUSAND;
lastSeenObjectIdEvent.SetTimestamp(timestampMS);
channel_->SendNotification(lastSeenObjectIdEvent);
}

View File

@ -95,7 +95,7 @@ private:
void AddHeapSnapshotChunk(char *data, int32_t size);
void ReportHeapSnapshotProgress(int32_t done, int32_t total);
void HeapStatsUpdate(HeapStat* updateData, int32_t count);
void LastSeenObjectId(int32_t lastSeenObjectId);
void LastSeenObjectId(int32_t lastSeenObjectId, int64_t timeStampUs);
void ResetProfiles();
private:
@ -136,12 +136,12 @@ private:
frontend_->HeapStatsUpdate(updateData, count);
}
void UpdateLastSeenObjectId(int32_t lastSeenObjectId) override
void UpdateLastSeenObjectId(int32_t lastSeenObjectId, int64_t timeStampUs) override
{
if (!Good()) {
return;
}
frontend_->LastSeenObjectId(lastSeenObjectId);
frontend_->LastSeenObjectId(lastSeenObjectId, timeStampUs);
}
private: