diff options
author | dominikg@chromium.org <dominikg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-05-13 19:40:58 +0000 |
---|---|---|
committer | dominikg@chromium.org <dominikg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-05-13 19:40:58 +0000 |
commit | 29d39a4adb6f9b2a4e05bb3f95140df2e3957ec7 (patch) | |
tree | ed44e1e28e3bbe7772fd44843bab4c226271e4a7 /cc/debug/rasterize_and_record_benchmark.cc | |
parent | 08035b96da9bb56a4a857f99756ae47743f2975b (diff) | |
download | chromium_src-29d39a4adb6f9b2a4e05bb3f95140df2e3957ec7.zip chromium_src-29d39a4adb6f9b2a4e05bb3f95140df2e3957ec7.tar.gz chromium_src-29d39a4adb6f9b2a4e05bb3f95140df2e3957ec7.tar.bz2 |
Use LapTimer in rasterize_and_record micro benchmark.
Timing record or rasterize on very small layers can be problematic. The
operations are very short and timing them individually can lead to quantization.
Use a LapTimer to run the operations we're timing for at least a specified
amount of time to avoid this problem.
Moves LapTimer from cc/test to cc/debug so it's accessible outside of testing
code.
BUG=
Review URL: https://codereview.chromium.org/279183002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@270170 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc/debug/rasterize_and_record_benchmark.cc')
-rw-r--r-- | cc/debug/rasterize_and_record_benchmark.cc | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/cc/debug/rasterize_and_record_benchmark.cc b/cc/debug/rasterize_and_record_benchmark.cc index b330e42..197fb29 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" @@ -27,12 +28,6 @@ const int kDefaultRecordRepeatCount = 100; 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 +116,25 @@ void RasterizeAndRecordBenchmark::RunOnLayer(PictureLayer* layer) { Picture::RecordingMode mode = static_cast<Picture::RecordingMode>(mode_index); base::TimeDelta min_time = base::TimeDelta::Max(); + + // Parameters for LapTimer. + const int kTimeLimitMillis = 1; + const int kWarmupRuns = 0; + const int kTimeCheckInterval = 1; + 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. + LapTimer timer(kWarmupRuns, + base::TimeDelta::FromMilliseconds(kTimeLimitMillis), + kTimeCheckInterval); + 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; } |