| 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 |
| 11 #define SkResultsWriter_DEFINED | 11 #define SkResultsWriter_DEFINED |
| 12 | 12 |
| 13 #include "BenchLogger.h" | 13 #include "BenchLogger.h" |
| 14 #include "SkJSONCPP.h" | 14 #include "SkJSONCPP.h" |
| 15 #include "SkOSFile.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" |
| 18 #include "SkTypes.h" | 19 #include "SkTypes.h" |
| 19 | 20 |
| 20 /** | 21 /** |
| 21 * Base class for writing out the bench results. | 22 * Base class for writing out the bench results. |
| 22 * | 23 * |
| 23 * Default implementation does nothing. | 24 * Default implementation does nothing. |
| 24 */ | 25 */ |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 // Don't record if nan, or -nan. | 110 // Don't record if nan, or -nan. |
| 110 if (sk_double_isnan(ms)) { | 111 if (sk_double_isnan(ms)) { |
| 111 return; | 112 return; |
| 112 } | 113 } |
| 113 SkASSERT(fConfig); | 114 SkASSERT(fConfig); |
| 114 (*fConfig)[name] = ms; | 115 (*fConfig)[name] = ms; |
| 115 } | 116 } |
| 116 | 117 |
| 117 // Flush to storage now please. | 118 // Flush to storage now please. |
| 118 virtual void flush() { | 119 virtual void flush() { |
| 120 SkString dirname = SkOSPath::Dirname(fFilename.c_str()); |
| 121 if (!sk_exists(dirname.c_str(), kWrite_SkFILE_Flag)) { |
| 122 if (!sk_mkdir(dirname.c_str())) { |
| 123 SkDebugf("Failed to create directory."); |
| 124 } |
| 125 } |
| 119 SkFILEWStream stream(fFilename.c_str()); | 126 SkFILEWStream stream(fFilename.c_str()); |
| 120 stream.writeText(Json::StyledWriter().write(fRoot).c_str()); | 127 stream.writeText(Json::StyledWriter().write(fRoot).c_str()); |
| 121 stream.flush(); | 128 stream.flush(); |
| 122 } | 129 } |
| 123 | 130 |
| 124 private: | 131 private: |
| 125 SkString fFilename; | 132 SkString fFilename; |
| 126 Json::Value fRoot; | 133 Json::Value fRoot; |
| 127 Json::Value& fResults; | 134 Json::Value& fResults; |
| 128 Json::Value* fBench; | 135 Json::Value* fBench; |
| 129 Json::Value* fConfig; | 136 Json::Value* fConfig; |
| 130 }; | 137 }; |
| 131 | 138 |
| 132 | 139 |
| 133 #endif | 140 #endif |
| OLD | NEW |