| 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..a22c2cd4d286dd06fa4998d2538a0944f0de5a63 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,12 +23,6 @@ namespace {
|
|
|
| const int kDefaultRasterizeRepeatCount = 100;
|
|
|
| -base::TimeTicks Now() {
|
| - return base::TimeTicks::IsThreadNowSupported()
|
| - ? base::TimeTicks::ThreadNow()
|
| - : base::TimeTicks::HighResNow();
|
| -}
|
| -
|
| class BenchmarkRasterTask : public Task {
|
| public:
|
| BenchmarkRasterTask(PicturePileImpl* picture_pile,
|
| @@ -46,24 +41,38 @@ class BenchmarkRasterTask : public Task {
|
| PicturePileImpl* picture_pile = picture_pile_->GetCloneForDrawingOnThread(
|
| RasterWorkerPool::GetPictureCloneIndexForCurrentThread());
|
|
|
| + // Parameters for LapTimer.
|
| + const int kTimeLimitMillis = 1;
|
| + const int kWarmupRuns = 0;
|
| + const int kTimeCheckInterval = 1;
|
| +
|
| 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.
|
| + LapTimer timer(kWarmupRuns,
|
| + base::TimeDelta::FromMilliseconds(kTimeLimitMillis),
|
| + kTimeCheckInterval);
|
| + 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;
|
| }
|
| }
|
|
|
|
|