| 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 27 matching lines...) Expand all Loading... |
| 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 timer(const char name[], double ms) {} |
| 48 |
| 49 // Flush to storage now please. |
| 50 virtual void flush() {} |
| 48 }; | 51 }; |
| 49 | 52 |
| 50 /** | 53 /** |
| 51 NanoJSONResultsWriter writes the test results out in the following | 54 NanoJSONResultsWriter writes the test results out in the following |
| 52 format: | 55 format: |
| 53 | 56 |
| 54 { | 57 { |
| 55 "key": { | 58 "key": { |
| 56 "arch": "Arm7", | 59 "arch": "Arm7", |
| 57 "gpu": "SGX540", | 60 "gpu": "SGX540", |
| (...skipping 14 matching lines...) Expand all Loading... |
| 72 class NanoJSONResultsWriter : public ResultsWriter { | 75 class NanoJSONResultsWriter : public ResultsWriter { |
| 73 public: | 76 public: |
| 74 explicit NanoJSONResultsWriter(const char filename[]) | 77 explicit NanoJSONResultsWriter(const char filename[]) |
| 75 : fFilename(filename) | 78 : fFilename(filename) |
| 76 , fRoot() | 79 , fRoot() |
| 77 , fResults(fRoot["results"]) | 80 , fResults(fRoot["results"]) |
| 78 , fBench(NULL) | 81 , fBench(NULL) |
| 79 , fConfig(NULL) {} | 82 , fConfig(NULL) {} |
| 80 | 83 |
| 81 ~NanoJSONResultsWriter() { | 84 ~NanoJSONResultsWriter() { |
| 82 SkFILEWStream stream(fFilename.c_str()); | 85 this->flush(); |
| 83 stream.writeText(Json::StyledWriter().write(fRoot).c_str()); | |
| 84 stream.flush(); | |
| 85 } | 86 } |
| 86 | 87 |
| 87 // Added under "key". | 88 // Added under "key". |
| 88 virtual void key(const char name[], const char value[]) { | 89 virtual void key(const char name[], const char value[]) { |
| 89 fRoot["key"][name] = value; | 90 fRoot["key"][name] = value; |
| 90 } | 91 } |
| 91 // Inserted directly into the root. | 92 // Inserted directly into the root. |
| 92 virtual void property(const char name[], const char value[]) { | 93 virtual void property(const char name[], const char value[]) { |
| 93 fRoot[name] = value; | 94 fRoot[name] = value; |
| 94 } | 95 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 106 } | 107 } |
| 107 virtual void timer(const char name[], double ms) { | 108 virtual void timer(const char name[], double ms) { |
| 108 // Don't record if nan, or -nan. | 109 // Don't record if nan, or -nan. |
| 109 if (sk_double_isnan(ms)) { | 110 if (sk_double_isnan(ms)) { |
| 110 return; | 111 return; |
| 111 } | 112 } |
| 112 SkASSERT(fConfig); | 113 SkASSERT(fConfig); |
| 113 (*fConfig)[name] = ms; | 114 (*fConfig)[name] = ms; |
| 114 } | 115 } |
| 115 | 116 |
| 117 // Flush to storage now please. |
| 118 virtual void flush() { |
| 119 SkFILEWStream stream(fFilename.c_str()); |
| 120 stream.writeText(Json::StyledWriter().write(fRoot).c_str()); |
| 121 stream.flush(); |
| 122 } |
| 123 |
| 116 private: | 124 private: |
| 117 SkString fFilename; | 125 SkString fFilename; |
| 118 Json::Value fRoot; | 126 Json::Value fRoot; |
| 119 Json::Value& fResults; | 127 Json::Value& fResults; |
| 120 Json::Value* fBench; | 128 Json::Value* fBench; |
| 121 Json::Value* fConfig; | 129 Json::Value* fConfig; |
| 122 }; | 130 }; |
| 123 | 131 |
| 124 | 132 |
| 125 #endif | 133 #endif |
| OLD | NEW |