Chromium Code Reviews| Index: cc/debug/rasterize_and_record_benchmark_impl.cc |
| diff --git a/cc/debug/rasterize_and_record_benchmark_impl.cc b/cc/debug/rasterize_and_record_benchmark_impl.cc |
| index 48d7c34f112a74569cb3b4a1d92d7a5fe40e4a87..c1c208eda4680c2875e16aa2e8fdcb6192f92860 100644 |
| --- a/cc/debug/rasterize_and_record_benchmark_impl.cc |
| +++ b/cc/debug/rasterize_and_record_benchmark_impl.cc |
| @@ -9,6 +9,7 @@ |
| #include "base/basictypes.h" |
| #include "base/values.h" |
| +#include "cc/debug/lap_timer.h" |
| #include "cc/layers/layer_impl.h" |
| #include "cc/layers/picture_layer_impl.h" |
| #include "cc/resources/raster_worker_pool.h" |
| @@ -22,11 +23,10 @@ namespace { |
| const int kDefaultRasterizeRepeatCount = 100; |
| -base::TimeTicks Now() { |
| - return base::TimeTicks::IsThreadNowSupported() |
| - ? base::TimeTicks::ThreadNow() |
| - : base::TimeTicks::HighResNow(); |
| -} |
| +// Parameters for LapTimer. |
| +const int kTimeLimitMillis = 1; |
| +const int kWarmupRuns = 0; |
| +const int kTimeCheckInterval = 1; |
| class BenchmarkRasterTask : public Task { |
| public: |
| @@ -46,24 +46,34 @@ class BenchmarkRasterTask : public Task { |
| PicturePileImpl* picture_pile = picture_pile_->GetCloneForDrawingOnThread( |
| RasterWorkerPool::GetPictureCloneIndexForCurrentThread()); |
|
danakj
2014/05/12 17:16:41
Can you move the LapTimer constant declarations do
|
| + LapTimer timer(kWarmupRuns, |
|
danakj
2014/05/12 17:16:41
This could go inside he for loop?
|
| + base::TimeDelta::FromMilliseconds(kTimeLimitMillis), |
| + kTimeCheckInterval); |
| for (size_t i = 0; i < repeat_count_; ++i) { |
| - SkBitmap bitmap; |
| - bitmap.allocPixels(SkImageInfo::MakeN32Premul(content_rect_.width(), |
| - content_rect_.height())); |
| - SkCanvas canvas(bitmap); |
| - PicturePileImpl::Analysis analysis; |
| - |
| - base::TimeTicks start = Now(); |
| - picture_pile->AnalyzeInRect( |
| - content_rect_, contents_scale_, &analysis, NULL); |
| - picture_pile->RasterToBitmap( |
| - &canvas, content_rect_, contents_scale_, NULL); |
| - 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 { |
| + SkBitmap bitmap; |
| + bitmap.allocPixels(SkImageInfo::MakeN32Premul(content_rect_.width(), |
| + content_rect_.height())); |
| + SkCanvas canvas(bitmap); |
| + PicturePileImpl::Analysis analysis; |
| + |
| + picture_pile->AnalyzeInRect( |
| + content_rect_, contents_scale_, &analysis, NULL); |
| + picture_pile->RasterToBitmap( |
| + &canvas, content_rect_, contents_scale_, NULL); |
| + |
| + is_solid_color_ = analysis.is_solid_color; |
| + |
| + timer.NextLap(); |
| + } while (!timer.HasTimeLimitExpired()); |
| + base::TimeDelta duration = |
| + base::TimeDelta::FromMillisecondsD(timer.MsPerLap()); |
| if (duration < best_time_) |
| best_time_ = duration; |
| - is_solid_color_ = analysis.is_solid_color; |
| } |
| } |