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

Side by Side Diff: tools/DumpRecord.cpp

Issue 344213003: Move BenchTimer to tools as Timer (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fixes Created 6 years, 6 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
OLDNEW
1 /* 1 /*
2 * Copyright 2014 Google Inc. 2 * Copyright 2014 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include <stdio.h> 8 #include <stdio.h>
9 9
10 #include "SkRecord.h" 10 #include "SkRecord.h"
11 #include "SkRecordDraw.h" 11 #include "SkRecordDraw.h"
12 12
13 #include "BenchTimer.h"
14 #include "DumpRecord.h" 13 #include "DumpRecord.h"
14 #include "Timer.h"
15 15
16 namespace { 16 namespace {
17 17
18 class Dumper { 18 class Dumper {
19 public: 19 public:
20 explicit Dumper(SkCanvas* canvas, int count, bool timeWithCommand) 20 explicit Dumper(SkCanvas* canvas, int count, bool timeWithCommand)
21 : fDigits(0) 21 : fDigits(0)
22 , fIndent(0) 22 , fIndent(0)
23 , fDraw(canvas) 23 , fDraw(canvas)
24 , fTimeWithCommand(timeWithCommand) { 24 , fTimeWithCommand(timeWithCommand) {
25 while (count > 0) { 25 while (count > 0) {
26 count /= 10; 26 count /= 10;
27 fDigits++; 27 fDigits++;
28 } 28 }
29 } 29 }
30 30
31 unsigned index() const { return fDraw.index(); } 31 unsigned index() const { return fDraw.index(); }
32 void next() { fDraw.next(); } 32 void next() { fDraw.next(); }
33 33
34 template <typename T> 34 template <typename T>
35 void operator()(const T& command) { 35 void operator()(const T& command) {
36 BenchTimer timer; 36 Timer timer;
37 timer.start(); 37 timer.start();
38 fDraw(command); 38 fDraw(command);
39 timer.end(); 39 timer.end();
40 40
41 this->print(command, timer.fCpu); 41 this->print(command, timer.fCpu);
42 } 42 }
43 43
44 void operator()(const SkRecords::NoOp&) { 44 void operator()(const SkRecords::NoOp&) {
45 // Move on without printing anything. 45 // Move on without printing anything.
46 } 46 }
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 104
105 void DumpRecord(const SkRecord& record, 105 void DumpRecord(const SkRecord& record,
106 SkCanvas* canvas, 106 SkCanvas* canvas,
107 bool timeWithCommand) { 107 bool timeWithCommand) {
108 for (Dumper dumper(canvas, record.count(), timeWithCommand); 108 for (Dumper dumper(canvas, record.count(), timeWithCommand);
109 dumper.index() < record.count(); 109 dumper.index() < record.count();
110 dumper.next()) { 110 dumper.next()) {
111 record.visit<void>(dumper.index(), dumper); 111 record.visit<void>(dumper.index(), dumper);
112 } 112 }
113 } 113 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698