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

Side by Side Diff: gpu/tools/compositor_model_bench/compositor_model_bench.cc

Issue 109043002: Move more file_util functions to base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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
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 // This tool is used to benchmark the render model used by the compositor 5 // This tool is used to benchmark the render model used by the compositor
6 6
7 // Most of this file is derived from the source of the tile_render_bench tool, 7 // Most of this file is derived from the source of the tile_render_bench tool,
8 // and has been changed to support running a sequence of independent 8 // and has been changed to support running a sequence of independent
9 // simulations for our different render models and test cases. 9 // simulations for our different render models and test cases.
10 10
(...skipping 20 matching lines...) Expand all
31 #include "base/memory/scoped_ptr.h" 31 #include "base/memory/scoped_ptr.h"
32 #include "base/message_loop/message_loop.h" 32 #include "base/message_loop/message_loop.h"
33 #include "base/time/time.h" 33 #include "base/time/time.h"
34 34
35 #include "gpu/tools/compositor_model_bench/render_model_utils.h" 35 #include "gpu/tools/compositor_model_bench/render_model_utils.h"
36 #include "gpu/tools/compositor_model_bench/render_models.h" 36 #include "gpu/tools/compositor_model_bench/render_models.h"
37 #include "gpu/tools/compositor_model_bench/render_tree.h" 37 #include "gpu/tools/compositor_model_bench/render_tree.h"
38 38
39 39
40 using base::TimeTicks; 40 using base::TimeTicks;
41 using file_util::CloseFile;
42 using base::DirectoryExists; 41 using base::DirectoryExists;
43 using file_util::OpenFile;
44 using base::PathExists; 42 using base::PathExists;
45 using std::queue; 43 using std::queue;
46 using std::string; 44 using std::string;
47 45
48 struct SimulationSpecification { 46 struct SimulationSpecification {
49 string simulation_name; 47 string simulation_name;
50 base::FilePath input_path; 48 base::FilePath input_path;
51 RenderModel model_under_test; 49 RenderModel model_under_test;
52 TimeTicks simulation_start_time; 50 TimeTicks simulation_start_time;
53 int frames_rendered; 51 int frames_rendered;
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 reinterpret_cast<XEvent*>(&ev)); 266 reinterpret_cast<XEvent*>(&ev));
269 267
270 base::MessageLoop::current()->PostTask( 268 base::MessageLoop::current()->PostTask(
271 FROM_HERE, 269 FROM_HERE,
272 base::Bind(&Simulator::UpdateLoop, weak_factory_.GetWeakPtr())); 270 base::Bind(&Simulator::UpdateLoop, weak_factory_.GetWeakPtr()));
273 } 271 }
274 272
275 void DumpOutput() { 273 void DumpOutput() {
276 LOG(INFO) << "Successfully ran " << sims_completed_.size() << " tests"; 274 LOG(INFO) << "Successfully ran " << sims_completed_.size() << " tests";
277 275
278 FILE* f = OpenFile(output_path_, "w"); 276 FILE* f = base::OpenFile(output_path_, "w");
279 277
280 if (!f) { 278 if (!f) {
281 LOG(ERROR) << "Failed to open output file " << 279 LOG(ERROR) << "Failed to open output file " <<
282 output_path_.LossyDisplayName(); 280 output_path_.LossyDisplayName();
283 exit(-1); 281 exit(-1);
284 } 282 }
285 283
286 LOG(INFO) << "Writing results to " << output_path_.LossyDisplayName(); 284 LOG(INFO) << "Writing results to " << output_path_.LossyDisplayName();
287 285
288 fputs("{\n\t\"results\": [\n", f); 286 fputs("{\n\t\"results\": [\n", f);
289 287
290 while (sims_completed_.size()) { 288 while (sims_completed_.size()) {
291 SimulationSpecification i = sims_completed_.front(); 289 SimulationSpecification i = sims_completed_.front();
292 fprintf(f, 290 fprintf(f,
293 "\t\t{\"simulation_name\":\"%s\",\n" 291 "\t\t{\"simulation_name\":\"%s\",\n"
294 "\t\t\t\"render_model\":\"%s\",\n" 292 "\t\t\t\"render_model\":\"%s\",\n"
295 "\t\t\t\"frames_drawn\":%d\n" 293 "\t\t\t\"frames_drawn\":%d\n"
296 "\t\t},\n", 294 "\t\t},\n",
297 i.simulation_name.c_str(), 295 i.simulation_name.c_str(),
298 ModelToString(i.model_under_test), 296 ModelToString(i.model_under_test),
299 i.frames_rendered); 297 i.frames_rendered);
300 sims_completed_.pop(); 298 sims_completed_.pop();
301 } 299 }
302 300
303 fputs("\t]\n}", f); 301 fputs("\t]\n}", f);
304 CloseFile(f); 302 base::CloseFile(f);
305 } 303 }
306 304
307 bool UpdateTestStatus() { 305 bool UpdateTestStatus() {
308 TimeTicks& current_start = sims_remaining_.front().simulation_start_time; 306 TimeTicks& current_start = sims_remaining_.front().simulation_start_time;
309 base::TimeDelta d = TimeTicks::Now() - current_start; 307 base::TimeDelta d = TimeTicks::Now() - current_start;
310 if (!current_start.is_null() && d.InSeconds() > seconds_per_test_) { 308 if (!current_start.is_null() && d.InSeconds() > seconds_per_test_) {
311 CleanupCurrentTest(); 309 CleanupCurrentTest();
312 sims_completed_.push(sims_remaining_.front()); 310 sims_completed_.push(sims_remaining_.front());
313 sims_remaining_.pop(); 311 sims_remaining_.pop();
314 } 312 }
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 } 393 }
396 } else { 394 } else {
397 LOG(INFO) << "(input path is a file)"; 395 LOG(INFO) << "(input path is a file)";
398 sim.QueueTest(inPath); 396 sim.QueueTest(inPath);
399 } 397 }
400 398
401 sim.Run(); 399 sim.Run();
402 400
403 return 0; 401 return 0;
404 } 402 }
OLDNEW
« no previous file with comments | « content/test/weburl_loader_mock_factory.cc ('k') | media/audio/android/audio_android_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698