Commit 738fcb80 authored by brianderson's avatar brianderson Committed by Commit bot

Avoid 64-bit divide when sampling timestamp

On some lower-end platforms, 64-bit integer division is
emulated or is significantly slower than 32-bit integer
division even if not emulated.

When converting ns to us in TimeTicks::Now(), we don't
need the range of a 64-bit integer because we are starting
with a 32-bit integer and making it smaller. There is no
need to convert it to 64-bits before the division.

BUG=none

Review URL: https://codereview.chromium.org/600013003

Cr-Commit-Position: refs/heads/master@{#297287}
parent 6e21296a
......@@ -98,7 +98,7 @@ base::TimeTicks ClockNow(clockid_t clk_id) {
absolute_micro =
(static_cast<int64>(ts.tv_sec) * base::Time::kMicrosecondsPerSecond) +
(static_cast<int64>(ts.tv_nsec) / base::Time::kNanosecondsPerMicrosecond);
(static_cast<int64>(ts.tv_nsec / base::Time::kNanosecondsPerMicrosecond));
return base::TimeTicks::FromInternalValue(absolute_micro);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment