Chromium Code Reviews| Index: cc/debug/rasterize_and_record_benchmark.cc |
| diff --git a/cc/debug/rasterize_and_record_benchmark.cc b/cc/debug/rasterize_and_record_benchmark.cc |
| index b330e429d35021bf477670e96e19ac18429ac83a..acf59a70fef5f17615d5161cbf235b220bfe1292 100644 |
| --- a/cc/debug/rasterize_and_record_benchmark.cc |
| +++ b/cc/debug/rasterize_and_record_benchmark.cc |
| @@ -11,6 +11,7 @@ |
| #include "base/basictypes.h" |
| #include "base/strings/stringprintf.h" |
| #include "base/values.h" |
| +#include "cc/debug/lap_timer.h" |
| #include "cc/debug/rasterize_and_record_benchmark_impl.h" |
| #include "cc/layers/layer.h" |
| #include "cc/layers/picture_layer.h" |
| @@ -24,15 +25,14 @@ namespace { |
| const int kDefaultRecordRepeatCount = 100; |
| +// Parameters for LapTimer. |
| +const int kTimeLimitMillis = 1; |
| +const int kWarmupRuns = 0; |
| +const int kTimeCheckInterval = 1; |
| + |
| const char* kModeSuffixes[Picture::RECORDING_MODE_COUNT] = { |
| "", "_sk_null_canvas", "_painting_disabled", "_skrecord"}; |
| -base::TimeTicks Now() { |
| - return base::TimeTicks::IsThreadNowSupported() |
| - ? base::TimeTicks::ThreadNow() |
| - : base::TimeTicks::HighResNow(); |
| -} |
| - |
| } // namespace |
| RasterizeAndRecordBenchmark::RasterizeAndRecordBenchmark( |
| @@ -121,12 +121,20 @@ void RasterizeAndRecordBenchmark::RunOnLayer(PictureLayer* layer) { |
| Picture::RecordingMode mode = |
| static_cast<Picture::RecordingMode>(mode_index); |
| base::TimeDelta min_time = base::TimeDelta::Max(); |
| + LapTimer timer(kWarmupRuns, |
|
danakj
2014/05/12 17:16:41
Can you move the LapTimer constant declarations do
|
| + base::TimeDelta::FromMilliseconds(kTimeLimitMillis), |
|
danakj
2014/05/12 17:16:41
And this could go inside the for loop?
|
| + kTimeCheckInterval); |
| for (int i = 0; i < record_repeat_count_; ++i) { |
| - base::TimeTicks start = Now(); |
| - scoped_refptr<Picture> picture = Picture::Create( |
| - visible_content_rect, painter, tile_grid_info, false, 0, mode); |
| - base::TimeTicks end = Now(); |
| - base::TimeDelta duration = end - start; |
| + // Run for a minimum amount of time to avoid problems with timer |
| + // quantization when the layer is very small. |
| + timer.Reset(); |
| + do { |
| + scoped_refptr<Picture> picture = Picture::Create( |
| + visible_content_rect, painter, tile_grid_info, false, 0, mode); |
| + timer.NextLap(); |
| + } while (!timer.HasTimeLimitExpired()); |
| + base::TimeDelta duration = |
| + base::TimeDelta::FromMillisecondsD(timer.MsPerLap()); |
| if (duration < min_time) |
| min_time = duration; |
| } |