OLD | NEW |
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 * Classes for writing out bench results in various formats. | 7 * Classes for writing out bench results in various formats. |
8 */ | 8 */ |
| 9 |
9 #ifndef SkPictureResultsWriter_DEFINED | 10 #ifndef SkPictureResultsWriter_DEFINED |
10 #define SkPictureResultsWriter_DEFINED | 11 #define SkPictureResultsWriter_DEFINED |
11 | 12 |
| 13 #include "BenchLogger.h" |
12 #include "ResultsWriter.h" | 14 #include "ResultsWriter.h" |
13 #include "SkBenchLogger.h" | |
14 #include "SkJSONCPP.h" | 15 #include "SkJSONCPP.h" |
15 #include "SkStream.h" | 16 #include "SkStream.h" |
16 #include "SkString.h" | 17 #include "SkString.h" |
17 #include "SkTArray.h" | 18 #include "SkTArray.h" |
| 19 #include "TimerData.h" |
18 | 20 |
19 /** | 21 /** |
20 * Base class for writing picture bench results. | 22 * Base class for writing picture bench results. |
21 */ | 23 */ |
22 class PictureResultsWriter : SkNoncopyable { | 24 class PictureResultsWriter : SkNoncopyable { |
23 public: | 25 public: |
24 enum TileFlags {kPurging, kAvg}; | 26 enum TileFlags {kPurging, kAvg}; |
25 | 27 |
26 PictureResultsWriter() {} | 28 PictureResultsWriter() {} |
27 virtual ~PictureResultsWriter() {} | 29 virtual ~PictureResultsWriter() {} |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 virtual void end() { | 88 virtual void end() { |
87 for(int i=0; i<fWriters.count(); ++i) { | 89 for(int i=0; i<fWriters.count(); ++i) { |
88 fWriters[i]->end(); | 90 fWriters[i]->end(); |
89 } | 91 } |
90 } | 92 } |
91 private: | 93 private: |
92 SkTArray<PictureResultsWriter*> fWriters; | 94 SkTArray<PictureResultsWriter*> fWriters; |
93 }; | 95 }; |
94 | 96 |
95 /** | 97 /** |
96 * Writes to SkBenchLogger to mimic original behavior | 98 * Writes to BenchLogger to mimic original behavior |
97 */ | 99 */ |
98 class PictureResultsLoggerWriter : public PictureResultsWriter { | 100 class PictureResultsLoggerWriter : public PictureResultsWriter { |
99 private: | 101 private: |
100 void logProgress(const char str[]) { | 102 void logProgress(const char str[]) { |
101 if(fLogger != NULL) { | 103 if(fLogger != NULL) { |
102 fLogger->logProgress(str); | 104 fLogger->logProgress(str); |
103 } | 105 } |
104 } | 106 } |
105 public: | 107 public: |
106 PictureResultsLoggerWriter(SkBenchLogger* log) | 108 PictureResultsLoggerWriter(BenchLogger* log) |
107 : fLogger(log), currentLine() {} | 109 : fLogger(log), currentLine() {} |
108 virtual void bench(const char name[], int32_t x, int32_t y) { | 110 virtual void bench(const char name[], int32_t x, int32_t y) { |
109 SkString result; | 111 SkString result; |
110 result.printf("running bench [%i %i] %s ", x, y, name); | 112 result.printf("running bench [%i %i] %s ", x, y, name); |
111 this->logProgress(result.c_str()); | 113 this->logProgress(result.c_str()); |
112 } | 114 } |
113 virtual void tileConfig(SkString configName) { | 115 virtual void tileConfig(SkString configName) { |
114 currentLine = configName; | 116 currentLine = configName; |
115 } | 117 } |
116 virtual void tileMeta(int x, int y, int tx, int ty) { | 118 virtual void tileMeta(int x, int y, int tx, int ty) { |
(...skipping 12 matching lines...) Expand all Loading... |
129 const TimerData::Result result, | 131 const TimerData::Result result, |
130 uint32_t timerTypes, | 132 uint32_t timerTypes, |
131 int numInnerLoops = 1) { | 133 int numInnerLoops = 1) { |
132 SkString results = data->getResult(format, result, | 134 SkString results = data->getResult(format, result, |
133 currentLine.c_str(), timerTypes, numInnerLoops); | 135 currentLine.c_str(), timerTypes, numInnerLoops); |
134 results.append("\n"); | 136 results.append("\n"); |
135 this->logProgress(results.c_str()); | 137 this->logProgress(results.c_str()); |
136 } | 138 } |
137 virtual void end() {} | 139 virtual void end() {} |
138 private: | 140 private: |
139 SkBenchLogger* fLogger; | 141 BenchLogger* fLogger; |
140 SkString currentLine; | 142 SkString currentLine; |
141 }; | 143 }; |
142 | 144 |
143 /** | 145 /** |
144 * This PictureResultsWriter collects data in a JSON node | 146 * This PictureResultsWriter collects data in a JSON node |
145 * | 147 * |
146 * The format is something like | 148 * The format is something like |
147 * { | 149 * { |
148 * benches: [ | 150 * benches: [ |
149 * { | 151 * { |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 } | 223 } |
222 private: | 224 private: |
223 SkString fFilename; | 225 SkString fFilename; |
224 Json::Value fRoot; | 226 Json::Value fRoot; |
225 Json::Value *fCurrentBench; | 227 Json::Value *fCurrentBench; |
226 Json::Value *fCurrentTileSet; | 228 Json::Value *fCurrentTileSet; |
227 Json::Value *fCurrentTile; | 229 Json::Value *fCurrentTile; |
228 }; | 230 }; |
229 | 231 |
230 #endif | 232 #endif |
OLD | NEW |