| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "cc/base/histograms.h" | 5 #include "cc/base/histograms.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cmath> |
| 8 #include <limits> | 9 #include <limits> |
| 9 | 10 |
| 10 #include "base/float_util.h" | |
| 11 #include "base/numerics/safe_conversions.h" | 11 #include "base/numerics/safe_conversions.h" |
| 12 | 12 |
| 13 namespace cc { | 13 namespace cc { |
| 14 | 14 |
| 15 // Minimum elapsed time of 1us to limit weighting of fast calls. | 15 // Minimum elapsed time of 1us to limit weighting of fast calls. |
| 16 static const int64 kMinimumTimeMicroseconds = 1; | 16 static const int64 kMinimumTimeMicroseconds = 1; |
| 17 | 17 |
| 18 ScopedUMAHistogramAreaTimerBase::ScopedUMAHistogramAreaTimerBase() : area_(0) { | 18 ScopedUMAHistogramAreaTimerBase::ScopedUMAHistogramAreaTimerBase() : area_(0) { |
| 19 } | 19 } |
| 20 | 20 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 31 | 31 |
| 32 // static | 32 // static |
| 33 void ScopedUMAHistogramAreaTimerBase::GetHistogramValues( | 33 void ScopedUMAHistogramAreaTimerBase::GetHistogramValues( |
| 34 base::TimeDelta elapsed, | 34 base::TimeDelta elapsed, |
| 35 int area, | 35 int area, |
| 36 Sample* time_microseconds, | 36 Sample* time_microseconds, |
| 37 Sample* pixels_per_ms) { | 37 Sample* pixels_per_ms) { |
| 38 elapsed = std::max( | 38 elapsed = std::max( |
| 39 elapsed, base::TimeDelta::FromMicroseconds(kMinimumTimeMicroseconds)); | 39 elapsed, base::TimeDelta::FromMicroseconds(kMinimumTimeMicroseconds)); |
| 40 double area_per_time = area / elapsed.InMillisecondsF(); | 40 double area_per_time = area / elapsed.InMillisecondsF(); |
| 41 DCHECK(!base::IsNaN(area_per_time)); | 41 DCHECK(!std::isnan(area_per_time)); |
| 42 *time_microseconds = base::saturated_cast<Sample>(elapsed.InMicroseconds()); | 42 *time_microseconds = base::saturated_cast<Sample>(elapsed.InMicroseconds()); |
| 43 *pixels_per_ms = base::saturated_cast<Sample>(area_per_time); | 43 *pixels_per_ms = base::saturated_cast<Sample>(area_per_time); |
| 44 } | 44 } |
| 45 | 45 |
| 46 } // namespace cc | 46 } // namespace cc |
| OLD | NEW |