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

Side by Side Diff: content/renderer/gpu/gpu_benchmarking_extension.cc

Issue 11027009: Use WebRenderingStats::Enumerate to populate benchmarking extension renderingStats() fields. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « content/common/gpu/gpu_rendering_stats.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/renderer/gpu/gpu_benchmarking_extension.h" 5 #include "content/renderer/gpu/gpu_benchmarking_extension.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/file_path.h" 9 #include "base/file_path.h"
10 #include "base/file_util.h" 10 #include "base/file_util.h"
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 DCHECK(file.isValid()); 74 DCHECK(file.isValid());
75 picture_.serialize(&file); 75 picture_.serialize(&file);
76 } 76 }
77 77
78 private: 78 private:
79 FilePath dirpath_; 79 FilePath dirpath_;
80 int layer_id_; 80 int layer_id_;
81 SkPicture picture_; 81 SkPicture picture_;
82 }; 82 };
83 83
84 class RenderingStatsEnumerator
85 : public WebRenderingStats::Enumerator,
86 public content::GpuRenderingStats::Enumerator {
87 public:
88 RenderingStatsEnumerator(v8::Handle<v8::Object> stats_object)
89 : stats_object_(stats_object) { }
90
91 virtual void addInt(const char* name, int value) {
92 stats_object_->Set(v8::String::New(name), v8::Integer::New(value));
93 }
94
95 virtual void addDouble(const char* name, double value) {
96 stats_object_->Set(v8::String::New(name), v8::Number::New(value));
97 }
98
99 virtual void addTimeDelta(const char* name, base::TimeDelta value) {
100 stats_object_->Set(v8::String::New(name),
101 v8::Number::New(value.InSecondsF()));
102 }
103
104 private:
105 v8::Handle<v8::Object> stats_object_;
106 };
107
84 } // namespace 108 } // namespace
85 109
86 namespace content { 110 namespace content {
87 111
88 class GpuBenchmarkingWrapper : public v8::Extension { 112 class GpuBenchmarkingWrapper : public v8::Extension {
89 public: 113 public:
90 GpuBenchmarkingWrapper() : 114 GpuBenchmarkingWrapper() :
91 v8::Extension(kGpuBenchmarkingExtensionName, 115 v8::Extension(kGpuBenchmarkingExtensionName,
92 "if (typeof(chrome) == 'undefined') {" 116 "if (typeof(chrome) == 'undefined') {"
93 " chrome = {};" 117 " chrome = {};"
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 172
149 RenderViewImpl* render_view_impl = RenderViewImpl::FromWebView(web_view); 173 RenderViewImpl* render_view_impl = RenderViewImpl::FromWebView(web_view);
150 if (!render_view_impl) 174 if (!render_view_impl)
151 return v8::Undefined(); 175 return v8::Undefined();
152 176
153 WebRenderingStats stats; 177 WebRenderingStats stats;
154 render_view_impl->GetRenderingStats(stats); 178 render_view_impl->GetRenderingStats(stats);
155 179
156 content::GpuRenderingStats gpu_stats; 180 content::GpuRenderingStats gpu_stats;
157 render_view_impl->GetGpuRenderingStats(&gpu_stats); 181 render_view_impl->GetGpuRenderingStats(&gpu_stats);
182
158 v8::Handle<v8::Object> stats_object = v8::Object::New(); 183 v8::Handle<v8::Object> stats_object = v8::Object::New();
159 stats_object->Set(v8::String::New("numAnimationFrames"), 184 RenderingStatsEnumerator enumerator(stats_object);
160 v8::Integer::New(stats.numAnimationFrames)); 185 stats.enumerateFields(&enumerator);
161 stats_object->Set(v8::String::New("numFramesSentToScreen"), 186 gpu_stats.enumerateFields(&enumerator);
162 v8::Integer::New(stats.numFramesSentToScreen));
163 stats_object->Set(v8::String::New("droppedFrameCount"),
164 v8::Integer::New(stats.droppedFrameCount));
165 stats_object->Set(v8::String::New("totalPaintTimeInSeconds"),
166 v8::Number::New(stats.totalPaintTimeInSeconds));
167 stats_object->Set(v8::String::New("totalRasterizeTimeInSeconds"),
168 v8::Number::New(stats.totalRasterizeTimeInSeconds));
169 stats_object->Set(v8::String::New("totalCommitTimeInSeconds"),
170 v8::Number::New(stats.totalCommitTimeInSeconds));
171 stats_object->Set(v8::String::New("totalCommitCount"),
172 v8::Integer::New(stats.totalCommitCount));
173
174 stats_object->Set(v8::String::New("globalTextureUploadCount"),
175 v8::Number::New(gpu_stats.global_texture_upload_count));
176 stats_object->Set(
177 v8::String::New("globalTotalTextureUploadTimeInSeconds"),
178 v8::Number::New(
179 gpu_stats.global_total_texture_upload_time.InSecondsF()));
180 stats_object->Set(v8::String::New("textureUploadCount"),
181 v8::Number::New(gpu_stats.texture_upload_count));
182 stats_object->Set(
183 v8::String::New("totalTextureUploadTimeInSeconds"),
184 v8::Number::New(gpu_stats.total_texture_upload_time.InSecondsF()));
185 stats_object->Set(
186 v8::String::New("globalTotalProcessingCommandsTimeInSeconds"),
187 v8::Number::New(
188 gpu_stats.global_total_processing_commands_time.InSecondsF()));
189 stats_object->Set(
190 v8::String::New("totalProcessingCommandsTimeInSeconds"),
191 v8::Number::New(
192 gpu_stats.total_processing_commands_time.InSecondsF()));
193 return stats_object; 187 return stats_object;
194 } 188 }
195 189
196 static v8::Handle<v8::Value> PrintToSkPicture(const v8::Arguments& args) { 190 static v8::Handle<v8::Value> PrintToSkPicture(const v8::Arguments& args) {
197 if (args.Length() != 1) 191 if (args.Length() != 1)
198 return v8::Undefined(); 192 return v8::Undefined();
199 193
200 v8::String::AsciiValue dirname(args[0]); 194 v8::String::AsciiValue dirname(args[0]);
201 if (dirname.length() == 0) 195 if (dirname.length() == 0)
202 return v8::Undefined(); 196 return v8::Undefined();
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 334
341 return results; 335 return results;
342 } 336 }
343 }; 337 };
344 338
345 v8::Extension* GpuBenchmarkingExtension::Get() { 339 v8::Extension* GpuBenchmarkingExtension::Get() {
346 return new GpuBenchmarkingWrapper(); 340 return new GpuBenchmarkingWrapper();
347 } 341 }
348 342
349 } // namespace content 343 } // namespace content
OLDNEW
« no previous file with comments | « content/common/gpu/gpu_rendering_stats.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698