OLD | NEW |
---|---|
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 Loading... | |
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 : public cc::RenderingStats::Enumerator { | |
85 public: | |
86 RenderingStatsEnumerator(v8::Handle<v8::Object> stats_object) | |
87 : stats_object(stats_object) { } | |
88 | |
89 virtual void addInt64(const char* name, int64 value) { | |
90 stats_object->Set(v8::String::New(name), v8::Number::New(value)); | |
91 } | |
92 | |
93 virtual void addDouble(const char* name, double value) { | |
94 stats_object->Set(v8::String::New(name), v8::Number::New(value)); | |
95 } | |
96 | |
97 private: | |
98 v8::Handle<v8::Object> stats_object; | |
99 }; | |
100 | |
84 } // namespace | 101 } // namespace |
85 | 102 |
86 namespace content { | 103 namespace content { |
87 | 104 |
88 class GpuBenchmarkingWrapper : public v8::Extension { | 105 class GpuBenchmarkingWrapper : public v8::Extension { |
89 public: | 106 public: |
90 GpuBenchmarkingWrapper() : | 107 GpuBenchmarkingWrapper() : |
91 v8::Extension(kGpuBenchmarkingExtensionName, | 108 v8::Extension(kGpuBenchmarkingExtensionName, |
92 "if (typeof(chrome) == 'undefined') {" | 109 "if (typeof(chrome) == 'undefined') {" |
93 " chrome = {};" | 110 " chrome = {};" |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
151 RenderViewImpl* render_view_impl = RenderViewImpl::FromWebView(web_view); | 168 RenderViewImpl* render_view_impl = RenderViewImpl::FromWebView(web_view); |
152 if (!render_view_impl) | 169 if (!render_view_impl) |
153 return v8::Undefined(); | 170 return v8::Undefined(); |
154 | 171 |
155 WebRenderingStatsImpl stats; | 172 WebRenderingStatsImpl stats; |
156 render_view_impl->GetRenderingStats(stats); | 173 render_view_impl->GetRenderingStats(stats); |
157 | 174 |
158 content::GpuRenderingStats gpu_stats; | 175 content::GpuRenderingStats gpu_stats; |
159 render_view_impl->GetGpuRenderingStats(&gpu_stats); | 176 render_view_impl->GetGpuRenderingStats(&gpu_stats); |
160 v8::Handle<v8::Object> stats_object = v8::Object::New(); | 177 v8::Handle<v8::Object> stats_object = v8::Object::New(); |
161 stats_object->Set(v8::String::New("numAnimationFrames"), | 178 |
162 v8::Number::New( | 179 RenderingStatsEnumerator enumerator(stats_object); |
163 stats.rendering_stats.numAnimationFrames)); | 180 stats.rendering_stats.enumerateFields(&enumerator); |
164 stats_object->Set(v8::String::New("numFramesSentToScreen"), | |
165 v8::Number::New( | |
166 stats.rendering_stats.numFramesSentToScreen)); | |
167 stats_object->Set(v8::String::New("droppedFrameCount"), | |
168 v8::Number::New( | |
169 stats.rendering_stats.droppedFrameCount)); | |
170 stats_object->Set(v8::String::New("totalPaintTimeInSeconds"), | |
171 v8::Number::New( | |
172 stats.rendering_stats.totalPaintTimeInSeconds)); | |
173 stats_object->Set(v8::String::New("totalRasterizeTimeInSeconds"), | |
174 v8::Number::New( | |
175 stats.rendering_stats.totalRasterizeTimeInSeconds)); | |
176 stats_object->Set(v8::String::New("totalCommitTimeInSeconds"), | |
177 v8::Number::New( | |
178 stats.rendering_stats.totalCommitTimeInSeconds)); | |
179 stats_object->Set(v8::String::New("totalCommitCount"), | |
180 v8::Number::New( | |
181 stats.rendering_stats.totalCommitCount)); | |
182 stats_object->Set(v8::String::New("numImplThreadScrolls"), | |
183 v8::Number::New( | |
184 stats.rendering_stats.numImplThreadScrolls)); | |
185 stats_object->Set(v8::String::New("numMainThreadScrolls"), | |
186 v8::Number::New( | |
187 stats.rendering_stats.numMainThreadScrolls)); | |
188 stats_object->Set(v8::String::New("totalPixelsPainted"), | |
189 v8::Number::New( | |
190 stats.rendering_stats.totalPixelsPainted)); | |
191 stats_object->Set(v8::String::New("totalPixelsRasterized"), | |
192 v8::Number::New( | |
193 stats.rendering_stats.totalPixelsRasterized)); | |
194 stats_object->Set(v8::String::New("numLayersInLayerTree"), | |
195 v8::Number::New( | |
196 stats.rendering_stats.numLayersInLayerTree)); | |
197 | 181 |
198 stats_object->Set(v8::String::New("globalTextureUploadCount"), | 182 stats_object->Set(v8::String::New("globalTextureUploadCount"), |
nduca
2012/11/28 21:27:35
can we do this for the gpu stats too, as a followu
hartmanng
2012/11/28 23:18:17
Done.
| |
199 v8::Number::New(gpu_stats.global_texture_upload_count)); | 183 v8::Number::New(gpu_stats.global_texture_upload_count)); |
200 stats_object->Set( | 184 stats_object->Set( |
201 v8::String::New("globalTotalTextureUploadTimeInSeconds"), | 185 v8::String::New("globalTotalTextureUploadTimeInSeconds"), |
202 v8::Number::New( | 186 v8::Number::New( |
203 gpu_stats.global_total_texture_upload_time.InSecondsF())); | 187 gpu_stats.global_total_texture_upload_time.InSecondsF())); |
204 stats_object->Set(v8::String::New("textureUploadCount"), | 188 stats_object->Set(v8::String::New("textureUploadCount"), |
205 v8::Number::New(gpu_stats.texture_upload_count)); | 189 v8::Number::New(gpu_stats.texture_upload_count)); |
206 stats_object->Set( | 190 stats_object->Set( |
207 v8::String::New("totalTextureUploadTimeInSeconds"), | 191 v8::String::New("totalTextureUploadTimeInSeconds"), |
208 v8::Number::New(gpu_stats.total_texture_upload_time.InSecondsF())); | 192 v8::Number::New(gpu_stats.total_texture_upload_time.InSecondsF())); |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
386 | 370 |
387 return results; | 371 return results; |
388 } | 372 } |
389 }; | 373 }; |
390 | 374 |
391 v8::Extension* GpuBenchmarkingExtension::Get() { | 375 v8::Extension* GpuBenchmarkingExtension::Get() { |
392 return new GpuBenchmarkingWrapper(); | 376 return new GpuBenchmarkingWrapper(); |
393 } | 377 } |
394 | 378 |
395 } // namespace content | 379 } // namespace content |
OLD | NEW |