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 |
10 #ifndef SkResultsWriter_DEFINED | 10 #ifndef SkResultsWriter_DEFINED |
(...skipping 16 matching lines...) Expand all Loading... |
27 virtual ~ResultsWriter() {} | 27 virtual ~ResultsWriter() {} |
28 | 28 |
29 // Record one key value pair that makes up a unique key for this type of run
, e.g. | 29 // Record one key value pair that makes up a unique key for this type of run
, e.g. |
30 // builder name, machine type, Debug/Release, etc. | 30 // builder name, machine type, Debug/Release, etc. |
31 virtual void key(const char name[], const char value[]) {} | 31 virtual void key(const char name[], const char value[]) {} |
32 | 32 |
33 // Record one key value pair that describes the run instance, e.g. git hash,
build number. | 33 // Record one key value pair that describes the run instance, e.g. git hash,
build number. |
34 virtual void property(const char name[], const char value[]) {} | 34 virtual void property(const char name[], const char value[]) {} |
35 | 35 |
36 // Denote the start of a specific benchmark. Once bench is called, | 36 // Denote the start of a specific benchmark. Once bench is called, |
37 // then config and timer can be called multiple times to record runs. | 37 // then config and metric can be called multiple times to record runs. |
38 virtual void bench(const char name[], int32_t x, int32_t y) {} | 38 virtual void bench(const char name[], int32_t x, int32_t y) {} |
39 | 39 |
40 // Record the specific configuration a bench is run under, such as "8888". | 40 // Record the specific configuration a bench is run under, such as "8888". |
41 virtual void config(const char name[]) {} | 41 virtual void config(const char name[]) {} |
42 | 42 |
43 // Record the options for a configuration, such as "GL_RENDERER". | 43 // Record the options for a configuration, such as "GL_RENDERER". |
44 virtual void configOption(const char name[], const char* value) {} | 44 virtual void configOption(const char name[], const char* value) {} |
45 | 45 |
46 // Record a single test metric. | 46 // Record a single test metric. |
47 virtual void timer(const char name[], double ms) {} | 47 virtual void metric(const char name[], double ms) {} |
48 | 48 |
49 // Flush to storage now please. | 49 // Flush to storage now please. |
50 virtual void flush() {} | 50 virtual void flush() {} |
51 }; | 51 }; |
52 | 52 |
53 /** | 53 /** |
54 NanoJSONResultsWriter writes the test results out in the following | 54 NanoJSONResultsWriter writes the test results out in the following |
55 format: | 55 format: |
56 | 56 |
57 { | 57 { |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 fResults[id.c_str()] = Json::Value(Json::objectValue); | 98 fResults[id.c_str()] = Json::Value(Json::objectValue); |
99 fBench = &fResults[id.c_str()]; | 99 fBench = &fResults[id.c_str()]; |
100 } | 100 } |
101 virtual void config(const char name[]) { | 101 virtual void config(const char name[]) { |
102 SkASSERT(fBench); | 102 SkASSERT(fBench); |
103 fConfig = &(*fBench)[name]; | 103 fConfig = &(*fBench)[name]; |
104 } | 104 } |
105 virtual void configOption(const char name[], const char* value) { | 105 virtual void configOption(const char name[], const char* value) { |
106 (*fConfig)["options"][name] = value; | 106 (*fConfig)["options"][name] = value; |
107 } | 107 } |
108 virtual void timer(const char name[], double ms) { | 108 virtual void metric(const char name[], double ms) { |
109 // Don't record if nan, or -nan. | 109 // Don't record if nan, or -nan. |
110 if (sk_double_isnan(ms)) { | 110 if (sk_double_isnan(ms)) { |
111 return; | 111 return; |
112 } | 112 } |
113 SkASSERT(fConfig); | 113 SkASSERT(fConfig); |
114 (*fConfig)[name] = ms; | 114 (*fConfig)[name] = ms; |
115 } | 115 } |
116 | 116 |
117 // Flush to storage now please. | 117 // Flush to storage now please. |
118 virtual void flush() { | 118 virtual void flush() { |
119 SkFILEWStream stream(fFilename.c_str()); | 119 SkFILEWStream stream(fFilename.c_str()); |
120 stream.writeText(Json::StyledWriter().write(fRoot).c_str()); | 120 stream.writeText(Json::StyledWriter().write(fRoot).c_str()); |
121 stream.flush(); | 121 stream.flush(); |
122 } | 122 } |
123 | 123 |
124 private: | 124 private: |
125 SkString fFilename; | 125 SkString fFilename; |
126 Json::Value fRoot; | 126 Json::Value fRoot; |
127 Json::Value& fResults; | 127 Json::Value& fResults; |
128 Json::Value* fBench; | 128 Json::Value* fBench; |
129 Json::Value* fConfig; | 129 Json::Value* fConfig; |
130 }; | 130 }; |
131 | 131 |
132 | 132 |
133 #endif | 133 #endif |
OLD | NEW |