| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "cc/base/histograms.h" |
| 6 |
| 7 #include <limits> |
| 8 |
| 9 #include "base/float_util.h" |
| 10 #include "base/numerics/safe_conversions.h" |
| 11 |
| 12 namespace cc { |
| 13 |
| 14 ScopedUMAHistogramAreaTimerBase::ScopedUMAHistogramAreaTimerBase() : area_(0) { |
| 15 } |
| 16 |
| 17 ScopedUMAHistogramAreaTimerBase::~ScopedUMAHistogramAreaTimerBase() { |
| 18 } |
| 19 |
| 20 bool ScopedUMAHistogramAreaTimerBase::GetHistogramValues( |
| 21 Sample* time_microseconds, |
| 22 Sample* pixels_per_ms) const { |
| 23 return GetHistogramValues( |
| 24 timer_.Elapsed(), area_.ValueOrDefault(std::numeric_limits<int>::max()), |
| 25 time_microseconds, pixels_per_ms); |
| 26 } |
| 27 |
| 28 // static |
| 29 bool ScopedUMAHistogramAreaTimerBase::GetHistogramValues( |
| 30 base::TimeDelta elapsed, |
| 31 int area, |
| 32 Sample* time_microseconds, |
| 33 Sample* pixels_per_ms) { |
| 34 double area_per_time = area / elapsed.InMillisecondsF(); |
| 35 if (base::IsNaN(area_per_time)) |
| 36 return false; |
| 37 *time_microseconds = base::saturated_cast<Sample>(elapsed.InMicroseconds()); |
| 38 *pixels_per_ms = base::saturated_cast<Sample>(area_per_time); |
| 39 return true; |
| 40 } |
| 41 |
| 42 } // namespace cc |
| OLD | NEW |