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

Side by Side Diff: cc/debug/picture_record_benchmark.cc

Issue 988693005: Chromium roll (https://codereview.chromium.org/976353002) (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: fixed bad android build patch Created 5 years, 9 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 unified diff | Download patch
« no previous file with comments | « cc/debug/picture_record_benchmark.h ('k') | cc/debug/rasterize_and_record_benchmark.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/debug/picture_record_benchmark.h" 5 #include "cc/debug/picture_record_benchmark.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/values.h" 10 #include "base/values.h"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 50
51 dimensions_.push_back(std::make_pair(width, height)); 51 dimensions_.push_back(std::make_pair(width, height));
52 } 52 }
53 } 53 }
54 54
55 PictureRecordBenchmark::~PictureRecordBenchmark() {} 55 PictureRecordBenchmark::~PictureRecordBenchmark() {}
56 56
57 void PictureRecordBenchmark::DidUpdateLayers(LayerTreeHost* host) { 57 void PictureRecordBenchmark::DidUpdateLayers(LayerTreeHost* host) {
58 LayerTreeHostCommon::CallFunctionForSubtree( 58 LayerTreeHostCommon::CallFunctionForSubtree(
59 host->root_layer(), 59 host->root_layer(),
60 base::Bind(&PictureRecordBenchmark::Run, base::Unretained(this))); 60 [this](Layer* layer) { layer->RunMicroBenchmark(this); });
61 61
62 scoped_ptr<base::ListValue> results(new base::ListValue()); 62 scoped_ptr<base::ListValue> results(new base::ListValue());
63 for (std::map<std::pair<int, int>, TotalTime>::iterator it = times_.begin(); 63 for (std::map<std::pair<int, int>, TotalTime>::iterator it = times_.begin();
64 it != times_.end(); 64 it != times_.end();
65 ++it) { 65 ++it) {
66 std::pair<int, int> dimensions = it->first; 66 std::pair<int, int> dimensions = it->first;
67 base::TimeDelta total_time = it->second.first; 67 base::TimeDelta total_time = it->second.first;
68 unsigned total_count = it->second.second; 68 unsigned total_count = it->second.second;
69 69
70 double average_time = 0.0; 70 double average_time = 0.0;
71 if (total_count > 0) 71 if (total_count > 0)
72 average_time = total_time.InMillisecondsF() / total_count; 72 average_time = total_time.InMillisecondsF() / total_count;
73 73
74 scoped_ptr<base::DictionaryValue> result(new base::DictionaryValue()); 74 scoped_ptr<base::DictionaryValue> result(new base::DictionaryValue());
75 result->SetInteger("width", dimensions.first); 75 result->SetInteger("width", dimensions.first);
76 result->SetInteger("height", dimensions.second); 76 result->SetInteger("height", dimensions.second);
77 result->SetInteger("samples_count", total_count); 77 result->SetInteger("samples_count", total_count);
78 result->SetDouble("time_ms", average_time); 78 result->SetDouble("time_ms", average_time);
79 79
80 results->Append(result.release()); 80 results->Append(result.release());
81 } 81 }
82 82
83 NotifyDone(results.Pass()); 83 NotifyDone(results.Pass());
84 } 84 }
85 85
86 void PictureRecordBenchmark::Run(Layer* layer) {
87 layer->RunMicroBenchmark(this);
88 }
89
90 void PictureRecordBenchmark::RunOnLayer(PictureLayer* layer) { 86 void PictureRecordBenchmark::RunOnLayer(PictureLayer* layer) {
91 ContentLayerClient* painter = layer->client(); 87 ContentLayerClient* painter = layer->client();
92 gfx::Size content_bounds = layer->content_bounds(); 88 gfx::Size content_bounds = layer->content_bounds();
93 89
94 gfx::Size tile_grid_size(kTileGridSize, kTileGridSize); 90 gfx::Size tile_grid_size(kTileGridSize, kTileGridSize);
95 91
96 for (size_t i = 0; i < dimensions_.size(); ++i) { 92 for (size_t i = 0; i < dimensions_.size(); ++i) {
97 std::pair<int, int> dimensions = dimensions_[i]; 93 std::pair<int, int> dimensions = dimensions_[i];
98 int width = dimensions.first; 94 int width = dimensions.first;
99 int height = dimensions.second; 95 int height = dimensions.second;
(...skipping 14 matching lines...) Expand all
114 base::TimeDelta duration = end - start; 110 base::TimeDelta duration = end - start;
115 TotalTime& total_time = times_[dimensions]; 111 TotalTime& total_time = times_[dimensions];
116 total_time.first += duration; 112 total_time.first += duration;
117 total_time.second++; 113 total_time.second++;
118 } 114 }
119 } 115 }
120 } 116 }
121 } 117 }
122 118
123 } // namespace cc 119 } // namespace cc
OLDNEW
« no previous file with comments | « cc/debug/picture_record_benchmark.h ('k') | cc/debug/rasterize_and_record_benchmark.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698