Skip to content

Commit

Permalink
deps: timeDeltas in cpu profiles are signed
Browse files Browse the repository at this point in the history
In some cases, they can take a negative value (don't really know why
because supposedly v8 uses a monotonic clock). We don't want to cast
them to unsigned to avoid overflows.

PR-URL: #254
Reviewed-By: Juan José Arboleda <[email protected]>
  • Loading branch information
santigimeno committed Jan 24, 2025
1 parent 6aa537f commit 0246f46
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions deps/v8/src/profiler/profile-generator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -885,8 +885,9 @@ void CpuProfileJSONSerializer::SerializeTimeDeltas() {
int count = profile_->samples_count();
base::TimeTicks lastTimestamp = profile_->start_time();
for (int i = 0; i < count; i++) {
writer_->AddNumber(static_cast<int>(
(profile_->sample(i).timestamp - lastTimestamp).InMicroseconds()));
int delta = static_cast<int>(
(profile_->sample(i).timestamp - lastTimestamp).InMicroseconds());
writer_->AddString(std::to_string(delta).c_str());
if (i != (count - 1)) writer_->AddString(",");
lastTimestamp = profile_->sample(i).timestamp;
}
Expand Down

0 comments on commit 0246f46

Please sign in to comment.