OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 SkResultsWriter_DEFINED | 10 #ifndef SkResultsWriter_DEFINED |
10 #define SkResultsWriter_DEFINED | 11 #define SkResultsWriter_DEFINED |
11 | 12 |
12 #include "SkBenchLogger.h" | 13 #include "BenchLogger.h" |
13 #include "SkJSONCPP.h" | 14 #include "SkJSONCPP.h" |
14 #include "SkStream.h" | 15 #include "SkStream.h" |
15 #include "SkString.h" | 16 #include "SkString.h" |
16 #include "SkTArray.h" | 17 #include "SkTArray.h" |
17 #include "SkTypes.h" | 18 #include "SkTypes.h" |
18 | 19 |
19 | |
20 /** | 20 /** |
21 * Base class for writing out the bench results. | 21 * Base class for writing out the bench results. |
22 * | 22 * |
23 * TODO(jcgregorio) Add info if tests fail to converge? | 23 * TODO(jcgregorio) Add info if tests fail to converge? |
24 */ | 24 */ |
25 class ResultsWriter : SkNoncopyable { | 25 class ResultsWriter : SkNoncopyable { |
26 public: | 26 public: |
27 virtual ~ResultsWriter() {}; | 27 virtual ~ResultsWriter() {}; |
28 | 28 |
29 // Records one option set for this run. All options must be set before | 29 // Records one option set for this run. All options must be set before |
(...skipping 13 matching lines...) Expand all Loading... |
43 // Call when all results are finished. | 43 // Call when all results are finished. |
44 virtual void end() = 0; | 44 virtual void end() = 0; |
45 }; | 45 }; |
46 | 46 |
47 /** | 47 /** |
48 * This ResultsWriter handles writing out the human readable format of the | 48 * This ResultsWriter handles writing out the human readable format of the |
49 * bench results. | 49 * bench results. |
50 */ | 50 */ |
51 class LoggerResultsWriter : public ResultsWriter { | 51 class LoggerResultsWriter : public ResultsWriter { |
52 public: | 52 public: |
53 explicit LoggerResultsWriter(SkBenchLogger& logger, const char* timeFormat) | 53 explicit LoggerResultsWriter(BenchLogger& logger, const char* timeFormat) |
54 : fLogger(logger) | 54 : fLogger(logger) |
55 , fTimeFormat(timeFormat) { | 55 , fTimeFormat(timeFormat) { |
56 fLogger.logProgress("skia bench:"); | 56 fLogger.logProgress("skia bench:"); |
57 } | 57 } |
58 virtual void option(const char name[], const char value[]) { | 58 virtual void option(const char name[], const char value[]) { |
59 fLogger.logProgress(SkStringPrintf(" %s=%s", name, value)); | 59 fLogger.logProgress(SkStringPrintf(" %s=%s", name, value)); |
60 } | 60 } |
61 virtual void bench(const char name[], int32_t x, int32_t y) { | 61 virtual void bench(const char name[], int32_t x, int32_t y) { |
62 fLogger.logProgress(SkStringPrintf( | 62 fLogger.logProgress(SkStringPrintf( |
63 "\nrunning bench [%3d %3d] %40s", x, y, name)); | 63 "\nrunning bench [%3d %3d] %40s", x, y, name)); |
64 } | 64 } |
65 virtual void config(const char name[]) { | 65 virtual void config(const char name[]) { |
66 fLogger.logProgress(SkStringPrintf(" %s:", name)); | 66 fLogger.logProgress(SkStringPrintf(" %s:", name)); |
67 } | 67 } |
68 virtual void timer(const char name[], double ms) { | 68 virtual void timer(const char name[], double ms) { |
69 fLogger.logProgress(SkStringPrintf(" %s = ", name)); | 69 fLogger.logProgress(SkStringPrintf(" %s = ", name)); |
70 fLogger.logProgress(SkStringPrintf(fTimeFormat, ms)); | 70 fLogger.logProgress(SkStringPrintf(fTimeFormat, ms)); |
71 } | 71 } |
72 virtual void end() { | 72 virtual void end() { |
73 fLogger.logProgress("\n"); | 73 fLogger.logProgress("\n"); |
74 } | 74 } |
75 private: | 75 private: |
76 SkBenchLogger& fLogger; | 76 BenchLogger& fLogger; |
77 const char* fTimeFormat; | 77 const char* fTimeFormat; |
78 }; | 78 }; |
79 | 79 |
80 /** | 80 /** |
81 * This ResultsWriter handles writing out the results in JSON. | 81 * This ResultsWriter handles writing out the results in JSON. |
82 * | 82 * |
83 * The output looks like (except compressed to a single line): | 83 * The output looks like (except compressed to a single line): |
84 * | 84 * |
85 * { | 85 * { |
86 * "options" : { | 86 * "options" : { |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 */ | 189 */ |
190 template <typename T> class CallEnd : SkNoncopyable { | 190 template <typename T> class CallEnd : SkNoncopyable { |
191 public: | 191 public: |
192 CallEnd(T& obj) : fObj(obj) {} | 192 CallEnd(T& obj) : fObj(obj) {} |
193 ~CallEnd() { fObj.end(); } | 193 ~CallEnd() { fObj.end(); } |
194 private: | 194 private: |
195 T& fObj; | 195 T& fObj; |
196 }; | 196 }; |
197 | 197 |
198 #endif | 198 #endif |
OLD | NEW |