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 | |
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
-rw-r--r-- | cc/cc.gyp | 2 | ||||
-rw-r--r-- | cc/cc_tests.gyp | 1 | ||||
-rw-r--r-- | cc/debug/lap_timer.cc (renamed from cc/test/lap_timer.cc) | 4 | ||||
-rw-r--r-- | cc/debug/lap_timer.h (renamed from cc/test/lap_timer.h) | 11 | ||||
-rw-r--r-- | cc/debug/rasterize_and_record_benchmark.cc | 30 | ||||
-rw-r--r-- | cc/debug/rasterize_and_record_benchmark_impl.cc | 49 | ||||
-rw-r--r-- | cc/layers/layer_perftest.cc | 2 | ||||
-rw-r--r-- | cc/layers/picture_layer_impl_perftest.cc | 2 | ||||
-rw-r--r-- | cc/resources/picture_layer_tiling_perftest.cc | 2 | ||||
-rw-r--r-- | cc/resources/picture_pile_impl_perftest.cc | 2 | ||||
-rw-r--r-- | cc/resources/raster_worker_pool_perftest.cc | 2 | ||||
-rw-r--r-- | cc/resources/task_graph_runner_perftest.cc | 2 | ||||
-rw-r--r-- | cc/resources/tile_manager_perftest.cc | 2 | ||||
-rw-r--r-- | cc/trees/layer_tree_host_common_perftest.cc | 2 | ||||
-rw-r--r-- | cc/trees/layer_tree_host_perftest.cc | 2 | ||||
-rw-r--r-- | cc/trees/occlusion_tracker_perftest.cc | 2 |
16 files changed, 68 insertions, 49 deletions
@@ -98,6 +98,8 @@ 'debug/frame_rate_counter.cc', 'debug/frame_rate_counter.h', 'debug/frame_viewer_instrumentation.h', + 'debug/lap_timer.cc', + 'debug/lap_timer.h', 'debug/layer_tree_debug_state.cc', 'debug/layer_tree_debug_state.h', 'debug/micro_benchmark.cc', diff --git a/cc/cc_tests.gyp b/cc/cc_tests.gyp index 8ef6803..218a140 100644 --- a/cc/cc_tests.gyp +++ b/cc/cc_tests.gyp @@ -313,7 +313,6 @@ 'resources/task_graph_runner_perftest.cc', 'resources/tile_manager_perftest.cc', 'test/cc_test_suite.cc', - 'test/lap_timer.cc', 'test/run_all_perftests.cc', 'trees/layer_tree_host_common_perftest.cc', 'trees/layer_tree_host_perftest.cc', diff --git a/cc/test/lap_timer.cc b/cc/debug/lap_timer.cc index f9738fb..27aaf34 100644 --- a/cc/test/lap_timer.cc +++ b/cc/debug/lap_timer.cc @@ -1,8 +1,8 @@ -// Copyright 2013 The Chromium Authors. All rights reserved. +// Copyright 2014 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "cc/test/lap_timer.h" +#include "cc/debug/lap_timer.h" #include "base/logging.h" diff --git a/cc/test/lap_timer.h b/cc/debug/lap_timer.h index 57ad322..7ec9a8c 100644 --- a/cc/test/lap_timer.h +++ b/cc/debug/lap_timer.h @@ -1,11 +1,12 @@ -// Copyright 2013 The Chromium Authors. All rights reserved. +// Copyright 2014 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CC_TEST_LAP_TIMER_H_ -#define CC_TEST_LAP_TIMER_H_ +#ifndef CC_DEBUG_LAP_TIMER_H_ +#define CC_DEBUG_LAP_TIMER_H_ #include "base/time/time.h" +#include "cc/base/cc_export.h" namespace cc { @@ -19,7 +20,7 @@ namespace cc { // If you set the time_limit then you can use HasTimeLimitExpired() to see if // the current accumulated time has crossed that threshold, with an optimization // that it only tests this every check_interval laps. -class LapTimer { +class CC_EXPORT LapTimer { public: LapTimer(int warmup_laps, base::TimeDelta time_limit, int check_interval); // Resets the timer back to it's starting state. @@ -60,4 +61,4 @@ class LapTimer { } // namespace cc -#endif // CC_TEST_LAP_TIMER_H_ +#endif // CC_DEBUG_LAP_TIMER_H_ 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; } diff --git a/cc/debug/rasterize_and_record_benchmark_impl.cc b/cc/debug/rasterize_and_record_benchmark_impl.cc index 48d7c34..a22c2cd 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; } } diff --git a/cc/layers/layer_perftest.cc b/cc/layers/layer_perftest.cc index 05753bb..a36f1f0 100644 --- a/cc/layers/layer_perftest.cc +++ b/cc/layers/layer_perftest.cc @@ -4,12 +4,12 @@ #include "cc/layers/layer.h" +#include "cc/debug/lap_timer.h" #include "cc/resources/layer_painter.h" #include "cc/test/fake_impl_proxy.h" #include "cc/test/fake_layer_tree_host.h" #include "cc/test/fake_layer_tree_host_client.h" #include "cc/test/fake_layer_tree_host_impl.h" -#include "cc/test/lap_timer.h" #include "testing/gtest/include/gtest/gtest.h" #include "testing/perf/perf_test.h" diff --git a/cc/layers/picture_layer_impl_perftest.cc b/cc/layers/picture_layer_impl_perftest.cc index 70befd9..26280c1 100644 --- a/cc/layers/picture_layer_impl_perftest.cc +++ b/cc/layers/picture_layer_impl_perftest.cc @@ -4,13 +4,13 @@ #include "cc/layers/picture_layer_impl.h" +#include "cc/debug/lap_timer.h" #include "cc/test/fake_impl_proxy.h" #include "cc/test/fake_layer_tree_host_impl.h" #include "cc/test/fake_output_surface.h" #include "cc/test/fake_picture_layer_impl.h" #include "cc/test/fake_picture_pile_impl.h" #include "cc/test/impl_side_painting_settings.h" -#include "cc/test/lap_timer.h" #include "cc/test/test_shared_bitmap_manager.h" #include "cc/trees/layer_tree_impl.h" #include "testing/gtest/include/gtest/gtest.h" diff --git a/cc/resources/picture_layer_tiling_perftest.cc b/cc/resources/picture_layer_tiling_perftest.cc index 4ccef0a..1e698b9 100644 --- a/cc/resources/picture_layer_tiling_perftest.cc +++ b/cc/resources/picture_layer_tiling_perftest.cc @@ -2,9 +2,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "cc/debug/lap_timer.h" #include "cc/resources/picture_layer_tiling.h" #include "cc/test/fake_picture_layer_tiling_client.h" -#include "cc/test/lap_timer.h" #include "testing/gtest/include/gtest/gtest.h" #include "testing/perf/perf_test.h" diff --git a/cc/resources/picture_pile_impl_perftest.cc b/cc/resources/picture_pile_impl_perftest.cc index 3cc8065..7ced0ea 100644 --- a/cc/resources/picture_pile_impl_perftest.cc +++ b/cc/resources/picture_pile_impl_perftest.cc @@ -4,9 +4,9 @@ #include "cc/resources/picture_pile_impl.h" +#include "cc/debug/lap_timer.h" #include "cc/test/fake_picture_pile_impl.h" #include "cc/test/fake_rendering_stats_instrumentation.h" -#include "cc/test/lap_timer.h" #include "testing/gtest/include/gtest/gtest.h" #include "testing/perf/perf_test.h" diff --git a/cc/resources/raster_worker_pool_perftest.cc b/cc/resources/raster_worker_pool_perftest.cc index 0689e50..a0b63ef 100644 --- a/cc/resources/raster_worker_pool_perftest.cc +++ b/cc/resources/raster_worker_pool_perftest.cc @@ -5,6 +5,7 @@ #include "cc/resources/raster_worker_pool.h" #include "base/time/time.h" +#include "cc/debug/lap_timer.h" #include "cc/output/context_provider.h" #include "cc/resources/direct_raster_worker_pool.h" #include "cc/resources/image_copy_raster_worker_pool.h" @@ -16,7 +17,6 @@ #include "cc/resources/scoped_resource.h" #include "cc/test/fake_output_surface.h" #include "cc/test/fake_output_surface_client.h" -#include "cc/test/lap_timer.h" #include "cc/test/test_context_support.h" #include "cc/test/test_shared_bitmap_manager.h" #include "cc/test/test_web_graphics_context_3d.h" diff --git a/cc/resources/task_graph_runner_perftest.cc b/cc/resources/task_graph_runner_perftest.cc index 2dff063..bfa4ebe 100644 --- a/cc/resources/task_graph_runner_perftest.cc +++ b/cc/resources/task_graph_runner_perftest.cc @@ -9,7 +9,7 @@ #include "base/memory/scoped_ptr.h" #include "base/time/time.h" #include "cc/base/completion_event.h" -#include "cc/test/lap_timer.h" +#include "cc/debug/lap_timer.h" #include "testing/gtest/include/gtest/gtest.h" #include "testing/perf/perf_test.h" diff --git a/cc/resources/tile_manager_perftest.cc b/cc/resources/tile_manager_perftest.cc index fcc7e4f..3f12461 100644 --- a/cc/resources/tile_manager_perftest.cc +++ b/cc/resources/tile_manager_perftest.cc @@ -3,6 +3,7 @@ // found in the LICENSE file. #include "base/time/time.h" +#include "cc/debug/lap_timer.h" #include "cc/resources/tile.h" #include "cc/resources/tile_priority.h" #include "cc/test/fake_impl_proxy.h" @@ -14,7 +15,6 @@ #include "cc/test/fake_tile_manager.h" #include "cc/test/fake_tile_manager_client.h" #include "cc/test/impl_side_painting_settings.h" -#include "cc/test/lap_timer.h" #include "cc/test/test_shared_bitmap_manager.h" #include "cc/test/test_tile_priorities.h" #include "cc/trees/layer_tree_impl.h" diff --git a/cc/trees/layer_tree_host_common_perftest.cc b/cc/trees/layer_tree_host_common_perftest.cc index 758bb4c..7fe0d99 100644 --- a/cc/trees/layer_tree_host_common_perftest.cc +++ b/cc/trees/layer_tree_host_common_perftest.cc @@ -12,10 +12,10 @@ #include "base/strings/string_piece.h" #include "base/threading/thread.h" #include "base/time/time.h" +#include "cc/debug/lap_timer.h" #include "cc/layers/layer.h" #include "cc/test/fake_content_layer_client.h" #include "cc/test/fake_layer_tree_host_client.h" -#include "cc/test/lap_timer.h" #include "cc/test/layer_tree_json_parser.h" #include "cc/test/layer_tree_test.h" #include "cc/test/paths.h" diff --git a/cc/trees/layer_tree_host_perftest.cc b/cc/trees/layer_tree_host_perftest.cc index 4afbf42..70b2a64 100644 --- a/cc/trees/layer_tree_host_perftest.cc +++ b/cc/trees/layer_tree_host_perftest.cc @@ -11,13 +11,13 @@ #include "base/path_service.h" #include "base/strings/string_piece.h" #include "base/time/time.h" +#include "cc/debug/lap_timer.h" #include "cc/layers/content_layer.h" #include "cc/layers/nine_patch_layer.h" #include "cc/layers/solid_color_layer.h" #include "cc/layers/texture_layer.h" #include "cc/resources/texture_mailbox.h" #include "cc/test/fake_content_layer_client.h" -#include "cc/test/lap_timer.h" #include "cc/test/layer_tree_json_parser.h" #include "cc/test/layer_tree_test.h" #include "cc/test/paths.h" diff --git a/cc/trees/occlusion_tracker_perftest.cc b/cc/trees/occlusion_tracker_perftest.cc index f6e5492..1506b2f 100644 --- a/cc/trees/occlusion_tracker_perftest.cc +++ b/cc/trees/occlusion_tracker_perftest.cc @@ -5,13 +5,13 @@ #include "cc/trees/occlusion_tracker.h" #include "base/time/time.h" +#include "cc/debug/lap_timer.h" #include "cc/layers/layer_iterator.h" #include "cc/layers/solid_color_layer_impl.h" #include "cc/test/fake_layer_tree_host_impl_client.h" #include "cc/test/fake_output_surface.h" #include "cc/test/fake_proxy.h" #include "cc/test/fake_rendering_stats_instrumentation.h" -#include "cc/test/lap_timer.h" #include "cc/test/test_shared_bitmap_manager.h" #include "cc/trees/layer_tree_host_impl.h" #include "cc/trees/layer_tree_impl.h" |