Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3437)

Unified Diff: cc/debug/rasterize_and_record_benchmark_impl.cc

Issue 279183002: Use LapTimer in rasterize_and_record micro benchmark. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add CC_EXPORT to LapTimer class. Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/debug/rasterize_and_record_benchmark.cc ('k') | cc/layers/layer_perftest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
}
}
« no previous file with comments | « cc/debug/rasterize_and_record_benchmark.cc ('k') | cc/layers/layer_perftest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698