Chromium Code Reviews| Index: tools/PictureResultsWriter.h |
| diff --git a/tools/PictureResultsWriter.h b/tools/PictureResultsWriter.h |
| index d4a15765f0325415e6bfebdcb075fa1b0a727a37..cccb0e0628c2c2aa836a0d5b3db1a1f142366a22 100644 |
| --- a/tools/PictureResultsWriter.h |
| +++ b/tools/PictureResultsWriter.h |
| @@ -10,6 +10,8 @@ |
| #ifndef SkPictureResultsWriter_DEFINED |
| #define SkPictureResultsWriter_DEFINED |
| + |
| +#include "PictureRenderer.h" |
| #include "BenchLogger.h" |
| #include "ResultsWriter.h" |
| #include "SkJSONCPP.h" |
| @@ -29,7 +31,7 @@ public: |
| virtual ~PictureResultsWriter() {} |
| virtual void bench(const char name[], int32_t x, int32_t y) = 0; |
| - virtual void tileConfig(SkString configName) = 0; |
| + virtual void logRenderer(sk_tools::PictureRenderer *pr) = 0; |
| virtual void tileMeta(int x, int y, int tx, int ty) = 0; |
| virtual void addTileFlag(PictureResultsWriter::TileFlags flag) = 0; |
| virtual void tileData( |
| @@ -59,9 +61,9 @@ public: |
| fWriters[i]->bench(name, x, y); |
| } |
| } |
| - virtual void tileConfig(SkString configName) { |
| + virtual void logRenderer(sk_tools::PictureRenderer *pr) { |
| for(int i=0; i<fWriters.count(); ++i) { |
| - fWriters[i]->tileConfig(configName); |
| + fWriters[i]->logRenderer(pr); |
| } |
| } |
| virtual void tileMeta(int x, int y, int tx, int ty) { |
| @@ -112,8 +114,8 @@ public: |
| result.printf("running bench [%i %i] %s ", x, y, name); |
| this->logProgress(result.c_str()); |
| } |
|
robertphillips
2014/06/24 20:49:52
OVERRIDE here ?
kelvinly
2014/06/24 22:25:19
Ah, sorry, didn't know that was a thing. Fixed
|
| - virtual void tileConfig(SkString configName) { |
| - currentLine = configName; |
| + virtual void logRenderer(sk_tools::PictureRenderer* renderer) { |
|
robertphillips
2014/06/24 20:49:51
fCurrentLine ?
kelvinly
2014/06/24 22:25:19
Done.
|
| + currentLine = renderer->getConfigName(); |
| } |
| virtual void tileMeta(int x, int y, int tx, int ty) { |
| currentLine.appendf(": tile [%i,%i] out of [%i,%i]", x, y, tx, ty); |
| @@ -172,61 +174,117 @@ private: |
| class PictureJSONResultsWriter : public PictureResultsWriter { |
| public: |
| - PictureJSONResultsWriter(const char filename[]) |
| - : fFilename(filename), |
| - fRoot(), |
| - fCurrentBench(NULL), |
| - fCurrentTileSet(NULL), |
| - fCurrentTile(NULL) {} |
| + PictureJSONResultsWriter(const char filename[], |
| + const char builderName[], |
| + int buildNumber, |
| + int timestamp, |
| + const char gitHash[], |
| + int gitNumber) |
| + : fStream(filename) |
| + , fParams() |
| + , fConfigString() { |
| + fBuilderName = SkString(builderName); |
| + fBuildNumber = buildNumber; |
| + fTimestamp = timestamp; |
| + fGitHash = SkString(gitHash); |
| + fGitNumber = gitNumber; |
| + fBuilderData = makeBuilderJSON(fBuilderName); |
| + } |
| virtual void bench(const char name[], int32_t x, int32_t y) { |
| - SkString sk_name(name); |
| - sk_name.append("_"); |
| - sk_name.appendS32(x); |
| - sk_name.append("_"); |
| - sk_name.appendS32(y); |
| - Json::Value* bench_node = SkFindNamedNode(&fRoot["benches"], sk_name.c_str()); |
| - fCurrentBench = &(*bench_node)["tileSets"]; |
| - } |
| - virtual void tileConfig(SkString configName) { |
| - SkASSERT(fCurrentBench != NULL); |
| - fCurrentTileSet = SkFindNamedNode(fCurrentBench, configName.c_str()); |
| - fCurrentTile = &(*fCurrentTileSet)["tiles"][0]; |
| - } |
| - virtual void tileMeta(int x, int y, int tx, int ty) { |
| - SkASSERT(fCurrentTileSet != NULL); |
| - (*fCurrentTileSet)["tx"] = tx; |
| - (*fCurrentTileSet)["ty"] = ty; |
| - fCurrentTile = &(*fCurrentTileSet)["tiles"][x+tx*y]; |
| + fBenchName = SkString(name); |
| } |
|
robertphillips
2014/06/24 20:49:51
OVERRIDE here ?
kelvinly
2014/06/24 22:25:19
Done.
|
| - virtual void addTileFlag(PictureResultsWriter::TileFlags flag) { |
| - SkASSERT(fCurrentTile != NULL); |
| - if(flag == PictureResultsWriter::kPurging) { |
| - (*fCurrentTile)["flags"]["purging"] = true; |
| - } else if(flag == PictureResultsWriter::kAvg) { |
| - (*fCurrentTile)["flags"]["averaged"] = true; |
| - } |
| + virtual void logRenderer(sk_tools::PictureRenderer* pr) { |
| + fParams = pr->getJSONConfig(); |
| + fConfigString = pr->getConfigName(); |
| } |
| + // Apparently tiles aren't used, so tileMeta is empty |
|
robertphillips
2014/06/24 20:49:51
OVERRIDE here ?
Don't need ';' here
kelvinly
2014/06/24 22:25:19
Done.
|
| + virtual void tileMeta(int x, int y, int tx, int ty) { ; } |
| + // Flags aren't used, so addTileFlag is empty |
|
robertphillips
2014/06/24 20:49:52
Same here
kelvinly
2014/06/24 22:25:19
Done.
|
| + virtual void addTileFlag(PictureResultsWriter::TileFlags flag) { ; } |
| virtual void tileData( |
| TimerData* data, |
| const char format[], |
| const TimerData::Result result, |
| uint32_t timerTypes, |
| int numInnerLoops = 1) { |
| - SkASSERT(fCurrentTile != NULL); |
| - (*fCurrentTile)["data"] = data->getJSON(timerTypes, result, numInnerLoops); |
| + Json::Value newData = data->getJSON(timerTypes, result, numInnerLoops); |
| + Json::Value combinedParams(fBuilderData); |
| + for(Json::ValueIterator iter = fParams.begin(); iter != fParams.end(); |
| + iter++) { |
| + combinedParams[iter.key().asString()]= *iter; |
| + } |
| + // For each set of timer data |
| + for(Json::ValueIterator iter = newData.begin(); iter != newData.end(); |
| + iter++) { |
| + Json::Value data; |
| + data["buildNumber"] = fBuildNumber; |
| + data["timestamp"] = fTimestamp; |
| + data["gitHash"] = fGitHash.c_str(); |
| + data["gitNumber"] = fGitNumber; |
| + data["isTrybot"] = fBuilderName.endsWith("Trybot"); |
| + |
| + data["params"] = combinedParams; |
| + data["params"]["benchName"] = fBenchName.c_str(); |
| + |
| + // Not including skpSize because that's deprecated? |
| + data["key"] = makeKey(iter.key().asString().c_str()).c_str(); |
| + // Get the data |
| + SkTArray<double> times; |
| + Json::Value val = *iter; |
| + for(Json::ValueIterator vals = val.begin(); vals != val.end(); |
| + vals++) { |
| + times.push_back((*vals).asDouble()); |
| + } |
| + // Because there's no sort I'll just remove the smallest |
| + // 25% of values |
| + int numValues = times.count(); |
| + double currentMin = 10000000.0f; |
| + for(int i = 0; i < numValues; i++) { |
| + if(times[i] < currentMin) { |
| + currentMin = times[i]; |
| + } |
| + } |
| + for(int i = 0; i < numValues*0.25f; i++) { |
| + double localMin = currentMin; |
| + for(int j = 0; j < numValues; j++) { |
| + if(times[i] > currentMin && times[i] < localMin) { |
| + localMin = times[i]; |
| + } |
| + } |
| + currentMin = localMin; |
| + } |
| + data["value"] = currentMin; |
| + data["params"]["measurementType"] = iter.key().asString(); |
| + fStream.writeText(Json::FastWriter().write(data).c_str()); |
| + } |
| } |
| virtual void end() { |
| - SkFILEWStream stream(fFilename.c_str()); |
| - stream.writeText(Json::FastWriter().write(fRoot).c_str()); |
| - stream.flush(); |
| + fStream.flush(); |
| } |
| private: |
| - SkString fFilename; |
| - Json::Value fRoot; |
| - Json::Value *fCurrentBench; |
| - Json::Value *fCurrentTileSet; |
| - Json::Value *fCurrentTile; |
| + SkString makeKey(const char measurementType[]) { |
| + SkString tmp(fBuilderName); |
| + tmp.append("_"); |
| + tmp.append(fBenchName); |
| + tmp.append("_"); |
| + tmp.append(fConfigString); |
| + tmp.append("_"); |
| + tmp.append(measurementType); |
| + return tmp; |
| + } |
| + |
| + SkFILEWStream fStream; |
| + Json::Value fBuilderData; |
| + SkString fBenchName; |
| + Json::Value fParams; |
| + |
| + SkString fConfigString; |
| + SkString fBuilderName; |
| + int fBuildNumber; |
| + int fTimestamp; |
| + SkString fGitHash; |
| + int fGitNumber; |
| }; |
| #endif |