Commit 2f4a7518 by Brian Sheedy Committed by Commit Bot

Refactor perf tests to fix metric/story swapping

Refactors the perf tests to fix the issue of metric and story being swapped, which causes issues when trying to convert to histograms. Specifically, does the following: 1. Rolls the version of src/tests/perf_tests/third_party/perf/ to Chromium 476dae823269c8d05b544271af97ad1adb0db8ee 2. Switch to using PerfResultReporter instead of PrintResult directly. 3. Split RenderTestParams::suffix into backend and story; backend is used as part of the metric, while story is used as the story. 4. Remove the "average" metric that was being automatically reported by ANGLEPerfTest, as reported results are automatically averaged. 5. Update the reported metric to more clearly distinguish between test, backend, and metric. It is now name_backend.metric. e.g. DrawCallPerf_vulkan.wall_time. Bug: chromium:923564,chromium:924618 Change-Id: I00cc191407052f23df57dbfa53b6fb088fc26960 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1762360 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarJonah Ryan-Davis <jonahr@google.com>
parent e2ea45ba
......@@ -117,9 +117,11 @@ def get_results(metric, extra_args=[]):
print(output)
sys.exit(3)
pattern = metric + r'= ([0-9.]+)'
# Results are reported in the format:
# name_backend.metric: story= value units.
pattern = r'\.' + metric + r':.*= ([0-9.]+)'
m = re.findall(pattern, output)
if m is None:
if not m:
print("Did not find the metric '%s' in the test output:" % metric)
print(output)
sys.exit(1)
......
......@@ -8,6 +8,8 @@ _angle_perf_test_common_sources = [
"perf_tests/ANGLEPerfTest.h",
"perf_tests/ANGLEPerfTestArgs.cpp",
"perf_tests/ANGLEPerfTestArgs.h",
"perf_tests/third_party/perf/perf_result_reporter.cc",
"perf_tests/third_party/perf/perf_result_reporter.h",
"perf_tests/third_party/perf/perf_test.cc",
"perf_tests/third_party/perf/perf_test.h",
"test_utils/angle_test_configs.cpp",
......
......@@ -159,10 +159,12 @@ void DumpTraceEventsToJSONFile(const std::vector<TraceEvent> &traceEvents,
} // anonymous namespace
ANGLEPerfTest::ANGLEPerfTest(const std::string &name,
const std::string &suffix,
const std::string &backend,
const std::string &story,
unsigned int iterationsPerStep)
: mName(name),
mSuffix(suffix),
mBackend(backend),
mStory(story),
mTimer(CreateTimer()),
mGPUTimeNs(0),
mSkipTest(false),
......@@ -170,7 +172,20 @@ ANGLEPerfTest::ANGLEPerfTest(const std::string &name,
mNumStepsPerformed(0),
mIterationsPerStep(iterationsPerStep),
mRunning(true)
{}
{
if (mStory == "")
{
mStory = "baseline_story";
}
if (mStory[0] == '_')
{
mStory = mStory.substr(1);
}
mReporter = std::make_unique<perf_test::PerfResultReporter>(mName + mBackend, mStory);
mReporter->RegisterImportantMetric(".wall_time", "ns");
mReporter->RegisterImportantMetric(".gpu_time", "ns");
mReporter->RegisterFyiMetric(".steps", "count");
}
ANGLEPerfTest::~ANGLEPerfTest()
{
......@@ -196,7 +211,7 @@ void ANGLEPerfTest::run()
// Calibration allows the perf test runner script to save some time.
if (gCalibration)
{
printResult("steps", static_cast<size_t>(mStepsToRun), "count", false);
mReporter->AddResult(".steps", static_cast<size_t>(mStepsToRun));
return;
}
}
......@@ -214,10 +229,6 @@ void ANGLEPerfTest::run()
doRunLoop(kMaximumRunTimeSeconds);
totalTime += printResults();
}
double average = totalTime / kNumTrials;
std::ostringstream averageString;
averageString << "for " << kNumTrials << " runs";
printResult("average", average, averageString.str(), false);
}
void ANGLEPerfTest::doRunLoop(double maxRunTime)
......@@ -247,22 +258,6 @@ void ANGLEPerfTest::doRunLoop(double maxRunTime)
mTimer->stop();
}
void ANGLEPerfTest::printResult(const std::string &trace,
double value,
const std::string &units,
bool important) const
{
perf_test::PrintResult(mName, mSuffix, trace, value, units, important);
}
void ANGLEPerfTest::printResult(const std::string &trace,
size_t value,
const std::string &units,
bool important) const
{
perf_test::PrintResult(mName, mSuffix, trace, value, units, important);
}
void ANGLEPerfTest::SetUp() {}
void ANGLEPerfTest::TearDown() {}
......@@ -275,8 +270,8 @@ double ANGLEPerfTest::printResults()
};
const char *clockNames[2] = {
"wall_time",
"gpu_time",
".wall_time",
".gpu_time",
};
// If measured gpu time is non-zero, print that too.
......@@ -288,19 +283,29 @@ double ANGLEPerfTest::printResults()
double secondsPerStep = elapsedTimeSeconds[i] / static_cast<double>(mNumStepsPerformed);
double secondsPerIteration = secondsPerStep / static_cast<double>(mIterationsPerStep);
// Give the result a different name to ensure separate graphs if we transition.
if (secondsPerIteration > 1e-3)
perf_test::MetricInfo metricInfo;
std::string units;
// Lazily register the metric, re-using the existing units if it is
// already registered.
if (!mReporter->GetMetricInfo(clockNames[i], &metricInfo))
{
double microSecondsPerIteration = secondsPerIteration * kMicroSecondsPerSecond;
retValue = microSecondsPerIteration;
printResult(clockNames[i], microSecondsPerIteration, "us", true);
units = secondsPerIteration > 1e-3 ? "us" : "ns";
mReporter->RegisterImportantMetric(clockNames[i], units);
}
else
{
double nanoSecPerIteration = secondsPerIteration * kNanoSecondsPerSecond;
retValue = nanoSecPerIteration;
printResult(clockNames[i], nanoSecPerIteration, "ns", true);
units = metricInfo.units;
}
if (units == "us")
{
retValue = secondsPerIteration * kMicroSecondsPerSecond;
}
else
{
retValue = secondsPerIteration * kNanoSecondsPerSecond;
}
mReporter->AddResult(clockNames[i], retValue);
}
return retValue;
}
......@@ -310,7 +315,7 @@ double ANGLEPerfTest::normalizedTime(size_t value) const
return static_cast<double>(value) / static_cast<double>(mNumStepsPerformed);
}
std::string RenderTestParams::suffix() const
std::string RenderTestParams::backend() const
{
std::stringstream strstr;
......@@ -360,8 +365,21 @@ std::string RenderTestParams::suffix() const
return strstr.str();
}
std::string RenderTestParams::story() const
{
return "";
}
std::string RenderTestParams::backendAndStory() const
{
return backend() + story();
}
ANGLERenderTest::ANGLERenderTest(const std::string &name, const RenderTestParams &testParams)
: ANGLEPerfTest(name, testParams.suffix(), OneFrame() ? 1 : testParams.iterationsPerStep),
: ANGLEPerfTest(name,
testParams.backend(),
testParams.story(),
OneFrame() ? 1 : testParams.iterationsPerStep),
mTestParams(testParams),
mGLWindow(nullptr),
mOSWindow(nullptr)
......
......@@ -13,11 +13,13 @@
#include <gtest/gtest.h>
#include <string>
#include <unordered_map>
#include <vector>
#include "platform/Platform.h"
#include "test_utils/angle_test_configs.h"
#include "test_utils/angle_test_instantiate.h"
#include "third_party/perf/perf_result_reporter.h"
#include "util/EGLWindow.h"
#include "util/OSWindow.h"
#include "util/Timer.h"
......@@ -55,7 +57,8 @@ class ANGLEPerfTest : public testing::Test, angle::NonCopyable
{
public:
ANGLEPerfTest(const std::string &name,
const std::string &suffix,
const std::string &backend,
const std::string &story,
unsigned int iterationsPerStep);
virtual ~ANGLEPerfTest();
......@@ -70,14 +73,6 @@ class ANGLEPerfTest : public testing::Test, angle::NonCopyable
protected:
void run();
void printResult(const std::string &trace,
double value,
const std::string &units,
bool important) const;
void printResult(const std::string &trace,
size_t value,
const std::string &units,
bool important) const;
void SetUp() override;
void TearDown() override;
......@@ -91,10 +86,12 @@ class ANGLEPerfTest : public testing::Test, angle::NonCopyable
void doRunLoop(double maxRunTime);
std::string mName;
std::string mSuffix;
std::string mBackend;
std::string mStory;
Timer *mTimer;
uint64_t mGPUTimeNs;
bool mSkipTest;
std::unique_ptr<perf_test::PerfResultReporter> mReporter;
private:
double printResults();
......@@ -109,7 +106,9 @@ struct RenderTestParams : public angle::PlatformParameters
{
virtual ~RenderTestParams() {}
virtual std::string suffix() const;
virtual std::string backend() const;
virtual std::string story() const;
std::string backendAndStory() const;
EGLint windowWidth = 64;
EGLint windowHeight = 64;
......
......@@ -41,22 +41,22 @@ struct BindingsParams final : public RenderTestParams
iterationsPerStep = kIterationsPerStep;
}
std::string suffix() const override;
std::string story() const override;
size_t numObjects;
AllocationStyle allocationStyle;
};
std::ostream &operator<<(std::ostream &os, const BindingsParams &params)
{
os << params.suffix().substr(1);
os << params.backendAndStory().substr(1);
return os;
}
std::string BindingsParams::suffix() const
std::string BindingsParams::story() const
{
std::stringstream strstr;
strstr << RenderTestParams::suffix();
strstr << RenderTestParams::story();
strstr << "_" << numObjects << "_objects";
switch (allocationStyle)
......
......@@ -30,7 +30,8 @@ class BitSetIteratorPerfTest : public ANGLEPerfTest
};
template <typename T>
BitSetIteratorPerfTest<T>::BitSetIteratorPerfTest() : ANGLEPerfTest("BitSetIteratorPerf", "_run", 1)
BitSetIteratorPerfTest<T>::BitSetIteratorPerfTest()
: ANGLEPerfTest("BitSetIteratorPerf", "", "_run", 1)
{}
template <typename T>
......
......@@ -103,16 +103,16 @@ struct BlitFramebufferParams final : public RenderTestParams
windowHeight = 256;
}
std::string suffix() const override
std::string story() const override
{
std::stringstream suffixStr;
suffixStr << RenderTestParams::suffix();
suffixStr << "_" << BufferTypeString(type);
std::stringstream storyStr;
storyStr << RenderTestParams::story();
storyStr << "_" << BufferTypeString(type);
if (samples > 1)
{
suffixStr << "_" << samples << "_samples";
storyStr << "_" << samples << "_samples";
}
return suffixStr.str();
return storyStr.str();
}
BufferType type = BufferType::COLOR;
......@@ -122,7 +122,7 @@ struct BlitFramebufferParams final : public RenderTestParams
std::ostream &operator<<(std::ostream &os, const BlitFramebufferParams &params)
{
os << params.suffix().substr(1);
os << params.backendAndStory().substr(1);
return os;
}
......
......@@ -33,7 +33,7 @@ struct BufferSubDataParams final : public RenderTestParams
updateRate = 1;
}
std::string suffix() const override;
std::string story() const override;
GLboolean vertexNormalized;
GLenum vertexType;
......@@ -47,7 +47,7 @@ struct BufferSubDataParams final : public RenderTestParams
std::ostream &operator<<(std::ostream &os, const BufferSubDataParams &params)
{
os << params.suffix().substr(1);
os << params.backendAndStory().substr(1);
return os;
}
......@@ -203,11 +203,11 @@ GLsizeiptr GetVertexData(GLenum type,
return triDataSize;
}
std::string BufferSubDataParams::suffix() const
std::string BufferSubDataParams::story() const
{
std::stringstream strstr;
strstr << RenderTestParams::suffix();
strstr << RenderTestParams::story();
if (vertexNormalized)
{
......
......@@ -33,7 +33,7 @@ struct ClearParams final : public RenderTestParams
textureSize = 16;
}
std::string suffix() const override;
std::string story() const override;
GLsizei fboSize;
GLsizei textureSize;
......@@ -41,15 +41,15 @@ struct ClearParams final : public RenderTestParams
std::ostream &operator<<(std::ostream &os, const ClearParams &params)
{
os << params.suffix().substr(1);
os << params.backendAndStory().substr(1);
return os;
}
std::string ClearParams::suffix() const
std::string ClearParams::story() const
{
std::stringstream strstr;
strstr << RenderTestParams::suffix();
strstr << RenderTestParams::story();
return strstr.str();
}
......
......@@ -264,7 +264,7 @@ class CompilerPerfTest : public ANGLEPerfTest,
};
CompilerPerfTest::CompilerPerfTest()
: ANGLEPerfTest("CompilerPerf", GetParam().testId, kNumIterationsPerStep)
: ANGLEPerfTest("CompilerPerf", "", GetParam().testId, kNumIterationsPerStep)
{}
void CompilerPerfTest::SetUp()
......
......@@ -23,7 +23,7 @@ struct DispatchComputePerfParams final : public RenderTestParams
minorVersion = 1;
}
std::string suffix() const override;
std::string story() const override;
unsigned int localSizeX = 16;
unsigned int localSizeY = 16;
......@@ -31,21 +31,21 @@ struct DispatchComputePerfParams final : public RenderTestParams
unsigned int textureHeight = 32;
};
std::string DispatchComputePerfParams::suffix() const
std::string DispatchComputePerfParams::story() const
{
std::stringstream suffixStr;
suffixStr << RenderTestParams::suffix();
std::stringstream storyStr;
storyStr << RenderTestParams::story();
if (eglParameters.deviceType == EGL_PLATFORM_ANGLE_DEVICE_TYPE_NULL_ANGLE)
{
suffixStr << "_null";
storyStr << "_null";
}
return suffixStr.str();
return storyStr.str();
}
std::ostream &operator<<(std::ostream &os, const DispatchComputePerfParams &params)
{
os << params.suffix().substr(1);
os << params.backendAndStory().substr(1);
return os;
}
......
......@@ -27,16 +27,16 @@ struct DrawArraysPerfParams : public DrawCallPerfParams
{
DrawArraysPerfParams(const DrawCallPerfParams &base) : DrawCallPerfParams(base) {}
std::string suffix() const override;
std::string story() const override;
StateChange stateChange = StateChange::NoChange;
};
std::string DrawArraysPerfParams::suffix() const
std::string DrawArraysPerfParams::story() const
{
std::stringstream strstr;
strstr << DrawCallPerfParams::suffix();
strstr << DrawCallPerfParams::story();
switch (stateChange)
{
......@@ -61,7 +61,7 @@ std::string DrawArraysPerfParams::suffix() const
std::ostream &operator<<(std::ostream &os, const DrawArraysPerfParams &params)
{
os << params.suffix().substr(1);
os << params.backendAndStory().substr(1);
return os;
}
......
......@@ -31,11 +31,11 @@ DrawCallPerfParams::DrawCallPerfParams()
DrawCallPerfParams::~DrawCallPerfParams() = default;
std::string DrawCallPerfParams::suffix() const
std::string DrawCallPerfParams::story() const
{
std::stringstream strstr;
strstr << RenderTestParams::suffix();
strstr << RenderTestParams::story();
if (numTris == 0)
{
......
......@@ -20,7 +20,7 @@ struct DrawCallPerfParams : public RenderTestParams
DrawCallPerfParams();
virtual ~DrawCallPerfParams();
std::string suffix() const override;
std::string story() const override;
double runTimeSeconds;
int numTris;
......
......@@ -35,11 +35,11 @@ struct DrawElementsPerfParams final : public DrawCallPerfParams
numTris = 2;
}
std::string suffix() const override
std::string story() const override
{
std::stringstream strstr;
strstr << DrawCallPerfParams::suffix();
strstr << DrawCallPerfParams::story();
if (indexBufferChanged)
{
......@@ -60,7 +60,7 @@ struct DrawElementsPerfParams final : public DrawCallPerfParams
std::ostream &operator<<(std::ostream &os, const DrawElementsPerfParams &params)
{
os << params.suffix().substr(1);
os << params.backendAndStory().substr(1);
return os;
}
......
......@@ -24,19 +24,19 @@ struct DynamicPromotionParams final : public RenderTestParams
{
DynamicPromotionParams() { iterationsPerStep = kIterationsPerStep; }
std::string suffix() const override;
std::string story() const override;
size_t vertexCount = 1024;
};
std::string DynamicPromotionParams::suffix() const
std::string DynamicPromotionParams::story() const
{
return RenderTestParams::suffix();
return RenderTestParams::story();
}
std::ostream &operator<<(std::ostream &os, const DynamicPromotionParams &params)
{
os << params.suffix().substr(1);
os << params.backendAndStory().substr(1);
return os;
}
......
......@@ -75,7 +75,7 @@ class EGLInitializePerfTest : public ANGLEPerfTest,
};
EGLInitializePerfTest::EGLInitializePerfTest()
: ANGLEPerfTest("EGLInitialize", "_run", 1), mOSWindow(nullptr), mDisplay(EGL_NO_DISPLAY)
: ANGLEPerfTest("EGLInitialize", "", "_run", 1), mOSWindow(nullptr), mDisplay(EGL_NO_DISPLAY)
{
auto platform = GetParam().eglParameters;
......@@ -121,6 +121,10 @@ void EGLInitializePerfTest::SetUp()
platformMethods->currentTime = CapturePlatform_currentTime;
platformMethods->histogramCustomCounts = CapturePlatform_histogramCustomCounts;
mReporter->RegisterImportantMetric(".LoadDLLs", "ms");
mReporter->RegisterImportantMetric(".D3D11CreateDevice", "ms");
mReporter->RegisterImportantMetric(".InitResources", "ms");
}
EGLInitializePerfTest::~EGLInitializePerfTest()
......@@ -141,9 +145,9 @@ void EGLInitializePerfTest::step()
void EGLInitializePerfTest::TearDown()
{
ANGLEPerfTest::TearDown();
printResult("LoadDLLs", normalizedTime(mCaptures.loadDLLsMS), "ms", true);
printResult("D3D11CreateDevice", normalizedTime(mCaptures.createDeviceMS), "ms", true);
printResult("InitResources", normalizedTime(mCaptures.initResourcesMS), "ms", true);
mReporter->AddResult(".LoadDLLs", normalizedTime(mCaptures.loadDLLsMS));
mReporter->AddResult(".D3D11CreateDevice", normalizedTime(mCaptures.createDeviceMS));
mReporter->AddResult(".InitResources", normalizedTime(mCaptures.initResourcesMS));
ANGLEResetDisplayPlatform(mDisplay);
}
......
......@@ -40,7 +40,7 @@ class EGLMakeCurrentPerfTest : public ANGLEPerfTest,
};
EGLMakeCurrentPerfTest::EGLMakeCurrentPerfTest()
: ANGLEPerfTest("EGLMakeCurrent", "_run", ITERATIONS),
: ANGLEPerfTest("EGLMakeCurrent", "", "_run", ITERATIONS),
mOSWindow(nullptr),
mDisplay(EGL_NO_DISPLAY),
mSurface(EGL_NO_SURFACE),
......
......@@ -18,7 +18,7 @@ namespace
{
struct IndexConversionPerfParams final : public RenderTestParams
{
std::string suffix() const override
std::string story() const override
{
std::stringstream strstr;
......@@ -27,7 +27,7 @@ struct IndexConversionPerfParams final : public RenderTestParams
strstr << "_index_range";
}
strstr << RenderTestParams::suffix();
strstr << RenderTestParams::story();
return strstr.str();
}
......@@ -41,7 +41,7 @@ struct IndexConversionPerfParams final : public RenderTestParams
// Provide a custom gtest parameter name function for IndexConversionPerfParams.
std::ostream &operator<<(std::ostream &stream, const IndexConversionPerfParams &param)
{
stream << param.suffix().substr(1);
stream << param.backendAndStory().substr(1);
return stream;
}
......
......@@ -158,7 +158,7 @@ class IndexDataManagerPerfTest : public ANGLEPerfTest
};
IndexDataManagerPerfTest::IndexDataManagerPerfTest()
: ANGLEPerfTest("IndexDataManger", "_run", kIterationsPerStep),
: ANGLEPerfTest("IndexDataManager", "", "_run", kIterationsPerStep),
mIndexDataManager(&mMockBufferFactory),
mIndexCount(4000),
mBufferSize(mIndexCount * sizeof(GLushort)),
......
......@@ -56,11 +56,11 @@ struct InstancingPerfParams final : public RenderTestParams
instancingEnabled = true;
}
std::string suffix() const override
std::string story() const override
{
std::stringstream strstr;
strstr << RenderTestParams::suffix();
strstr << RenderTestParams::story();
if (!instancingEnabled)
{
......@@ -77,7 +77,7 @@ struct InstancingPerfParams final : public RenderTestParams
std::ostream &operator<<(std::ostream &os, const InstancingPerfParams &params)
{
os << params.suffix().substr(1);
os << params.backendAndStory().substr(1);
return os;
}
......
......@@ -37,7 +37,7 @@ struct InterleavedAttributeDataParams final : public RenderTestParams
std::ostream &operator<<(std::ostream &os, const InterleavedAttributeDataParams &params)
{
os << params.suffix().substr(1);
os << params.backendAndStory().substr(1);
if (params.eglParameters.majorVersion != EGL_DONT_CARE)
{
......
......@@ -49,10 +49,10 @@ struct LinkProgramParams final : public RenderTestParams
threadOption = threadOptionIn;
}
std::string suffix() const override
std::string story() const override
{
std::stringstream strstr;
strstr << RenderTestParams::suffix();
strstr << RenderTestParams::story();
if (taskOption == TaskOption::CompileOnly)
{
......@@ -86,7 +86,7 @@ struct LinkProgramParams final : public RenderTestParams
std::ostream &operator<<(std::ostream &os, const LinkProgramParams &params)
{
os << params.suffix().substr(1);
os << params.backendAndStory().substr(1);
return os;
}
......
......@@ -90,9 +90,9 @@ struct MultiviewPerfParams final : public RenderTestParams
multiviewExtension = multiviewExtensionIn;
}
std::string suffix() const override
std::string story() const override
{
std::string name = RenderTestParams::suffix();
std::string name = RenderTestParams::story();
switch (multiviewOption)
{
case MultiviewOption::NoAcceleration:
......@@ -133,7 +133,7 @@ struct MultiviewPerfParams final : public RenderTestParams
std::ostream &operator<<(std::ostream &os, const MultiviewPerfParams &params)
{
os << params.suffix().substr(1);
os << params.backendAndStory().substr(1);
return os;
}
......
......@@ -37,7 +37,7 @@ struct PointSpritesParams final : public RenderTestParams
numVaryings = 3;
}
std::string suffix() const override;
std::string story() const override;
unsigned int count;
float size;
......@@ -46,7 +46,7 @@ struct PointSpritesParams final : public RenderTestParams
std::ostream &operator<<(std::ostream &os, const PointSpritesParams &params)
{
os << params.suffix().substr(1);
os << params.backendAndStory().substr(1);
return os;
}
......@@ -66,11 +66,11 @@ class PointSpritesBenchmark : public ANGLERenderTest,
RNG mRNG;
};
std::string PointSpritesParams::suffix() const
std::string PointSpritesParams::story() const
{
std::stringstream strstr;
strstr << RenderTestParams::suffix() << "_" << count << "_" << size << "px"
strstr << RenderTestParams::story() << "_" << count << "_" << size << "px"
<< "_" << numVaryings << "vars";
return strstr.str();
......
......@@ -23,7 +23,7 @@ class ResultPerfTest : public ANGLEPerfTest
void step() override;
};
ResultPerfTest::ResultPerfTest() : ANGLEPerfTest("ResultPerf", "_run", kIterationsPerStep) {}
ResultPerfTest::ResultPerfTest() : ANGLEPerfTest("ResultPerf", "", "_run", kIterationsPerStep) {}
ANGLE_NOINLINE angle::Result ExternalCall()
{
......
......@@ -41,7 +41,7 @@ struct TextureSamplingParams final : public RenderTestParams
kernelSize = 3;
}
std::string suffix() const override;
std::string story() const override;
unsigned int numSamplers;
unsigned int textureSize;
unsigned int kernelSize;
......@@ -49,15 +49,15 @@ struct TextureSamplingParams final : public RenderTestParams
std::ostream &operator<<(std::ostream &os, const TextureSamplingParams &params)
{
os << params.suffix().substr(1);
os << params.backendAndStory().substr(1);
return os;
}
std::string TextureSamplingParams::suffix() const
std::string TextureSamplingParams::story() const
{
std::stringstream strstr;
strstr << RenderTestParams::suffix() << "_" << numSamplers << "samplers";
strstr << RenderTestParams::story() << "_" << numSamplers << "samplers";
return strstr.str();
}
......
......@@ -35,7 +35,7 @@ struct TextureUploadParams final : public RenderTestParams
webgl = false;
}
std::string suffix() const override;
std::string story() const override;
GLsizei baseSize;
GLsizei subImageSize;
......@@ -45,15 +45,15 @@ struct TextureUploadParams final : public RenderTestParams
std::ostream &operator<<(std::ostream &os, const TextureUploadParams &params)
{
os << params.suffix().substr(1);
os << params.backendAndStory().substr(1);
return os;
}
std::string TextureUploadParams::suffix() const
std::string TextureUploadParams::story() const
{
std::stringstream strstr;
strstr << RenderTestParams::suffix();
strstr << RenderTestParams::story();
if (webgl)
{
......
......@@ -39,7 +39,7 @@ struct TexturesParams final : public RenderTestParams
webgl = false;
}
std::string suffix() const override;
std::string story() const override;
size_t numTextures;
size_t textureRebindFrequency;
size_t textureStateUpdateFrequency;
......@@ -50,15 +50,15 @@ struct TexturesParams final : public RenderTestParams
std::ostream &operator<<(std::ostream &os, const TexturesParams &params)
{
os << params.suffix().substr(1);
os << params.backendAndStory().substr(1);
return os;
}
std::string TexturesParams::suffix() const
std::string TexturesParams::story() const
{
std::stringstream strstr;
strstr << RenderTestParams::suffix();
strstr << RenderTestParams::story();
strstr << "_" << numTextures << "_textures";
strstr << "_" << textureRebindFrequency << "_rebind";
strstr << "_" << textureStateUpdateFrequency << "_state";
......
......@@ -67,7 +67,7 @@ struct UniformsParams final : public RenderTestParams
windowHeight = 720;
}
std::string suffix() const override;
std::string story() const override;
size_t numVertexUniforms = 200;
size_t numFragmentUniforms = 200;
......@@ -79,15 +79,15 @@ struct UniformsParams final : public RenderTestParams
std::ostream &operator<<(std::ostream &os, const UniformsParams &params)
{
os << params.suffix().substr(1);
os << params.backendAndStory().substr(1);
return os;
}
std::string UniformsParams::suffix() const
std::string UniformsParams::story() const
{
std::stringstream strstr;
strstr << RenderTestParams::suffix();
strstr << RenderTestParams::story();
if (eglParameters.deviceType == EGL_PLATFORM_ANGLE_DEVICE_TYPE_NULL_ANGLE)
{
......
......@@ -37,7 +37,7 @@ struct VulkanBarriersPerfParams final : public RenderTestParams
doSlowFragmentShaders = slowFS;
}
std::string suffix() const override;
std::string story() const override;
// Static parameters
static constexpr int kImageSizes[3] = {256, 512, 4096};
......@@ -50,7 +50,7 @@ constexpr int VulkanBarriersPerfParams::kImageSizes[];
std::ostream &operator<<(std::ostream &os, const VulkanBarriersPerfParams &params)
{
os << params.suffix().substr(1);
os << params.backendAndStory().substr(1);
return os;
}
......@@ -102,11 +102,11 @@ class VulkanBarriersPerfBenchmark : public ANGLERenderTest,
static constexpr size_t kHugeSizeIndex = 2;
};
std::string VulkanBarriersPerfParams::suffix() const
std::string VulkanBarriersPerfParams::story() const
{
std::ostringstream sout;
sout << RenderTestParams::suffix();
sout << RenderTestParams::story();
if (doLargeTransfers)
{
......
......@@ -59,7 +59,7 @@ using CommandBufferImpl = void (*)(sample_info &info,
struct CommandBufferTestParams
{
CommandBufferImpl CBImplementation;
std::string suffix;
std::string story;
int frames = NUM_FRAMES;
int buffers = NUM_CMD_BUFFERS;
};
......@@ -89,7 +89,7 @@ class VulkanCommandBufferPerfTest : public ANGLEPerfTest,
};
VulkanCommandBufferPerfTest::VulkanCommandBufferPerfTest()
: ANGLEPerfTest("VulkanCommandBufferPerfTest", GetParam().suffix, GetParam().frames)
: ANGLEPerfTest("VulkanCommandBufferPerfTest", "", GetParam().story, GetParam().frames)
{
mInfo = {};
mSampleTitle = "Draw Textured Cube";
......@@ -564,7 +564,7 @@ CommandBufferTestParams PrimaryCBHundredIndividualParams()
{
CommandBufferTestParams params;
params.CBImplementation = PrimaryCommandBufferBenchmarkHundredIndividual;
params.suffix = "_PrimaryCB_Submit_100_With_1_Draw";
params.story = "_PrimaryCB_Submit_100_With_1_Draw";
return params;
}
......@@ -572,7 +572,7 @@ CommandBufferTestParams PrimaryCBOneWithOneHundredParams()
{
CommandBufferTestParams params;
params.CBImplementation = PrimaryCommandBufferBenchmarkOneWithOneHundred;
params.suffix = "_PrimaryCB_Submit_1_With_100_Draw";
params.story = "_PrimaryCB_Submit_1_With_100_Draw";
return params;
}
......@@ -580,7 +580,7 @@ CommandBufferTestParams SecondaryCBParams()
{
CommandBufferTestParams params;
params.CBImplementation = SecondaryCommandBufferBenchmark;
params.suffix = "_SecondaryCB_Submit_1_With_100_Draw_In_Individual_Secondary";
params.story = "_SecondaryCB_Submit_1_With_100_Draw_In_Individual_Secondary";
return params;
}
......@@ -588,7 +588,7 @@ CommandBufferTestParams CommandPoolDestroyParams()
{
CommandBufferTestParams params;
params.CBImplementation = CommandPoolDestroyBenchmark;
params.suffix = "_Reset_CBs_With_Destroy_Command_Pool";
params.story = "_Reset_CBs_With_Destroy_Command_Pool";
return params;
}
......@@ -596,7 +596,7 @@ CommandBufferTestParams CommandPoolHardResetParams()
{
CommandBufferTestParams params;
params.CBImplementation = CommandPoolHardResetBenchmark;
params.suffix = "_Reset_CBs_With_Hard_Reset_Command_Pool";
params.story = "_Reset_CBs_With_Hard_Reset_Command_Pool";
return params;
}
......@@ -604,7 +604,7 @@ CommandBufferTestParams CommandPoolSoftResetParams()
{
CommandBufferTestParams params;
params.CBImplementation = CommandPoolSoftResetBenchmark;
params.suffix = "_Reset_CBs_With_Soft_Reset_Command_Pool";
params.story = "_Reset_CBs_With_Soft_Reset_Command_Pool";
return params;
}
......@@ -612,7 +612,7 @@ CommandBufferTestParams CommandBufferExplicitHardResetParams()
{
CommandBufferTestParams params;
params.CBImplementation = CommandBufferExplicitHardResetBenchmark;
params.suffix = "_Reset_CBs_With_Explicit_Hard_Reset_Command_Buffers";
params.story = "_Reset_CBs_With_Explicit_Hard_Reset_Command_Buffers";
return params;
}
......@@ -620,7 +620,7 @@ CommandBufferTestParams CommandBufferExplicitSoftResetParams()
{
CommandBufferTestParams params;
params.CBImplementation = CommandBufferExplicitSoftResetBenchmark;
params.suffix = "_Reset_CBs_With_Explicit_Soft_Reset_Command_Buffers";
params.story = "_Reset_CBs_With_Explicit_Soft_Reset_Command_Buffers";
return params;
}
......@@ -628,7 +628,7 @@ CommandBufferTestParams CommandBufferImplicitResetParams()
{
CommandBufferTestParams params;
params.CBImplementation = CommandBufferImplicitResetBenchmark;
params.suffix = "_Reset_CBs_With_Implicit_Reset_Command_Buffers";
params.story = "_Reset_CBs_With_Implicit_Reset_Command_Buffers";
return params;
}
......
......@@ -38,7 +38,7 @@ class VulkanPipelineCachePerfTest : public ANGLEPerfTest
};
VulkanPipelineCachePerfTest::VulkanPipelineCachePerfTest()
: ANGLEPerfTest("VulkanPipelineCachePerf", "", kIterationsPerStep)
: ANGLEPerfTest("VulkanPipelineCachePerf", "", "", kIterationsPerStep)
{}
VulkanPipelineCachePerfTest::~VulkanPipelineCachePerfTest()
......
......@@ -12,7 +12,7 @@
#include <stdio.h>
#include <sstream>
#include "../perf_tests/third_party/perf/perf_test.h"
#include "../perf_tests/third_party/perf/perf_result_reporter.h"
#include "ANGLEPerfTestArgs.h"
#include "common/platform.h"
#include "common/system_utils.h"
......@@ -108,6 +108,10 @@ class GLMark2Benchmark : public testing::TestWithParam<GLMark2BenchmarkTestParam
default:
break;
}
std::string story = kBenchmarks[std::get<1>(GetParam())].name;
mReporter = std::make_unique<perf_test::PerfResultReporter>("glmark2_" + mBackend, story);
mReporter->RegisterImportantMetric(".fps", "fps");
mReporter->RegisterImportantMetric(".score", "score");
}
void run()
......@@ -244,9 +248,7 @@ class GLMark2Benchmark : public testing::TestWithParam<GLMark2BenchmarkTestParam
if (!completeRun)
{
const std::string kBenchmarkPrefix = "glmark2_";
perf_test::PrintResult(kBenchmarkPrefix + benchmarkName, '_' + mBackend, "fps", fps,
"", true);
mReporter->AddResult(".fps", fps);
}
}
......@@ -260,11 +262,12 @@ class GLMark2Benchmark : public testing::TestWithParam<GLMark2BenchmarkTestParam
if (completeRun)
{
perf_test::PrintResult("glmark2", '_' + mBackend, "score", score, "", true);
mReporter->AddResult(".score", score);
}
}
std::string mBackend = "invalid";
std::unique_ptr<perf_test::PerfResultReporter> mReporter;
};
TEST_P(GLMark2Benchmark, Run)
......
diff --git a/tests/perf_tests/third_party/perf/perf_test.cc b/tests/perf_tests/third_party/perf/perf_test.cc
index 0d5abc0..7364330 100644
--- a/tests/perf_tests/third_party/perf/perf_test.cc
+++ b/tests/perf_tests/third_party/perf/perf_test.cc
@@ -2,16 +2,51 @@
diff --git a/src/tests/perf_tests/third_party/perf/angle-mods.patch b/src/tests/perf_tests/third_party/perf/angle-mods.patch
index a758818c0..e69de29bb 100644
--- a/src/tests/perf_tests/third_party/perf/angle-mods.patch
+++ b/src/tests/perf_tests/third_party/perf/angle-mods.patch
@@ -1,176 +0,0 @@
-diff --git a/src/tests/perf_tests/third_party/perf/angle-mods.patch b/src/tests/perf_tests/third_party/perf/angle-mods.patch
-index d0b640289..e69de29bb 100644
---- a/src/tests/perf_tests/third_party/perf/angle-mods.patch
-+++ b/src/tests/perf_tests/third_party/perf/angle-mods.patch
-@@ -1,61 +0,0 @@
--diff --git a/tests/perf_tests/third_party/perf/perf_test.cc b/tests/perf_tests/third_party/perf/perf_test.cc
--index 0d5abc0..7364330 100644
----- a/tests/perf_tests/third_party/perf/perf_test.cc
--+++ b/tests/perf_tests/third_party/perf/perf_test.cc
--@@ -2,16 +2,51 @@
-- // Use of this source code is governed by a BSD-style license that can be
-- // found in the LICENSE file.
--
---#include "testing/perf/perf_test.h"
--+#include "perf_test.h"
--
-- #include <stdio.h>
---
---#include "base/logging.h"
---#include "base/strings/string_number_conversions.h"
---#include "base/strings/stringprintf.h"
--+#include <stdarg.h>
--+#include <vector>
--
-- namespace {
--
--+namespace base {
--+
--+std::string FormatString(const char *fmt, va_list vararg) {
--+ static std::vector<char> buffer(512);
--+
--+ // Attempt to just print to the current buffer
--+ int len = vsnprintf(&buffer[0], buffer.size(), fmt, vararg);
--+ if (len < 0 || static_cast<size_t>(len) >= buffer.size()) {
--+ // Buffer was not large enough, calculate the required size and resize the buffer
--+ len = vsnprintf(NULL, 0, fmt, vararg);
--+ buffer.resize(len + 1);
--+
--+ // Print again
--+ vsnprintf(&buffer[0], buffer.size(), fmt, vararg);
--+ }
--+
--+ return std::string(buffer.data(), len);
--+}
--+
--+std::string StringPrintf(const char *fmt, ...) {
--+ va_list vararg;
--+ va_start(vararg, fmt);
--+ std::string result = FormatString(fmt, vararg);
--+ va_end(vararg);
--+ return result;
--+}
--+
--+std::string UintToString(unsigned int value) {
--+ return StringPrintf("%u", value);
--+}
--+
--+std::string DoubleToString(double value) {
--+ return StringPrintf("%.10lf", value);
--+}
--+
--+}
--+
-- std::string ResultsToString(const std::string& measurement,
-- const std::string& modifier,
-- const std::string& trace,
-diff --git a/src/tests/perf_tests/third_party/perf/perf_result_reporter.cc b/src/tests/perf_tests/third_party/perf/perf_result_reporter.cc
-index 272e6ca17..3a6a41f01 100644
---- a/src/tests/perf_tests/third_party/perf/perf_result_reporter.cc
-+++ b/src/tests/perf_tests/third_party/perf/perf_result_reporter.cc
-@@ -2,9 +2,9 @@
- // Use of this source code is governed by a BSD-style license that can be
- // found in the LICENSE file.
-
--#include "testing/perf/perf_result_reporter.h"
--#include "base/logging.h"
--#include "testing/perf/perf_test.h"
-+#include "perf_result_reporter.h"
-+#include "anglebase/logging.h"
-+#include "perf_test.h"
-
- namespace perf_test {
-
-diff --git a/src/tests/perf_tests/third_party/perf/perf_test.cc b/src/tests/perf_tests/third_party/perf/perf_test.cc
-index 0b0b666db..bc3a6bb8d 100644
---- a/src/tests/perf_tests/third_party/perf/perf_test.cc
-+++ b/src/tests/perf_tests/third_party/perf/perf_test.cc
-@@ -2,16 +2,47 @@
- // Use of this source code is governed by a BSD-style license that can be
- // found in the LICENSE file.
-
--#include "testing/perf/perf_test.h"
-+#include "perf_test.h"
-
-+#include <stdarg.h>
- #include <stdio.h>
--
--#include "base/logging.h"
--#include "base/strings/string_number_conversions.h"
--#include "base/strings/stringprintf.h"
-+#include <vector>
-
- namespace {
-
-+std::string FormatString(const char *fmt, va_list vararg) {
-+ static std::vector<char> buffer(512);
-+
-+ // Attempt to just print to the current buffer
-+ int len = vsnprintf(&buffer[0], buffer.size(), fmt, vararg);
-+ if (len < 0 || static_cast<size_t>(len) >= buffer.size()) {
-+ // Buffer was not large enough, calculate the required size and resize the buffer
-+ len = vsnprintf(NULL, 0, fmt, vararg);
-+ buffer.resize(len + 1);
-+
-+ // Print again
-+ vsnprintf(&buffer[0], buffer.size(), fmt, vararg);
-+ }
-+
-+ return std::string(buffer.data(), len);
-+}
-+
-+std::string StringPrintf(const char *fmt, ...) {
-+ va_list vararg;
-+ va_start(vararg, fmt);
-+ std::string result = FormatString(fmt, vararg);
-+ va_end(vararg);
-+ return result;
-+}
-+
-+std::string NumberToString(size_t value) {
-+ return StringPrintf("%u", value);
-+}
-+
-+std::string NumberToString(double value) {
-+ return StringPrintf("%.10lf", value);
-+}
-+
- std::string ResultsToString(const std::string& measurement,
- const std::string& modifier,
- const std::string& trace,
-@@ -23,7 +54,7 @@ std::string ResultsToString(const std::string& measurement,
- // <*>RESULT <graph_name>: <trace_name>= <value> <units>
- // <*>RESULT <graph_name>: <trace_name>= {<mean>, <std deviation>} <units>
- // <*>RESULT <graph_name>: <trace_name>= [<value>,value,value,...,] <units>
-- return base::StringPrintf("%sRESULT %s%s: %s= %s%s%s %s\n",
-+ return StringPrintf("%sRESULT %s%s: %s= %s%s%s %s\n",
- important ? "*" : "", measurement.c_str(), modifier.c_str(),
- trace.c_str(), prefix.c_str(), values.c_str(), suffix.c_str(),
- units.c_str());
-@@ -53,7 +84,7 @@ void PrintResult(const std::string& measurement,
- size_t value,
- const std::string& units,
- bool important) {
-- PrintResultsImpl(measurement, modifier, trace, base::NumberToString(value),
-+ PrintResultsImpl(measurement, modifier, trace, NumberToString(value),
- std::string(), std::string(), units, important);
- }
-
-@@ -63,7 +94,7 @@ void PrintResult(const std::string& measurement,
- double value,
- const std::string& units,
- bool important) {
-- PrintResultsImpl(measurement, modifier, trace, base::NumberToString(value),
-+ PrintResultsImpl(measurement, modifier, trace, NumberToString(value),
- std::string(), std::string(), units, important);
- }
-
-@@ -75,7 +106,7 @@ void AppendResult(std::string& output,
- const std::string& units,
- bool important) {
- output +=
-- ResultsToString(measurement, modifier, trace, base::NumberToString(value),
-+ ResultsToString(measurement, modifier, trace, NumberToString(value),
- std::string(), std::string(), units, important);
- }
-
diff --git a/src/tests/perf_tests/third_party/perf/perf_result_reporter.cc b/src/tests/perf_tests/third_party/perf/perf_result_reporter.cc
index 272e6ca17..fcbfa78b3 100644
--- a/src/tests/perf_tests/third_party/perf/perf_result_reporter.cc
+++ b/src/tests/perf_tests/third_party/perf/perf_result_reporter.cc
@@ -2,72 +2,77 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "testing/perf/perf_result_reporter.h"
-#include "base/logging.h"
-#include "testing/perf/perf_test.h"
+#include "perf_result_reporter.h"
+#include "anglebase/logging.h"
+#include "perf_test.h"
-namespace perf_test {
+namespace perf_test
+{
-PerfResultReporter::PerfResultReporter(const std::string& metric_basename,
- const std::string& story_name)
- : metric_basename_(metric_basename), story_name_(story_name) {}
+PerfResultReporter::PerfResultReporter(const std::string &metric_basename,
+ const std::string &story_name)
+ : metric_basename_(metric_basename), story_name_(story_name)
+{}
PerfResultReporter::~PerfResultReporter() = default;
-void PerfResultReporter::RegisterFyiMetric(const std::string& metric_suffix,
- const std::string& units) {
- RegisterMetric(metric_suffix, units, false);
+void PerfResultReporter::RegisterFyiMetric(const std::string &metric_suffix,
+ const std::string &units)
+{
+ RegisterMetric(metric_suffix, units, false);
}
-void PerfResultReporter::RegisterImportantMetric(
- const std::string& metric_suffix,
- const std::string& units) {
- RegisterMetric(metric_suffix, units, true);
+void PerfResultReporter::RegisterImportantMetric(const std::string &metric_suffix,
+ const std::string &units)
+{
+ RegisterMetric(metric_suffix, units, true);
}
-void PerfResultReporter::AddResult(const std::string& metric_suffix,
- size_t value) {
- auto iter = metric_map_.find(metric_suffix);
- CHECK(iter != metric_map_.end());
+void PerfResultReporter::AddResult(const std::string &metric_suffix, size_t value)
+{
+ auto iter = metric_map_.find(metric_suffix);
+ CHECK(iter != metric_map_.end());
- PrintResult(metric_basename_, metric_suffix, story_name_, value,
- iter->second.units, iter->second.important);
+ PrintResult(metric_basename_, metric_suffix, story_name_, value, iter->second.units,
+ iter->second.important);
}
-void PerfResultReporter::AddResult(const std::string& metric_suffix,
- double value) {
- auto iter = metric_map_.find(metric_suffix);
- CHECK(iter != metric_map_.end());
+void PerfResultReporter::AddResult(const std::string &metric_suffix, double value)
+{
+ auto iter = metric_map_.find(metric_suffix);
+ CHECK(iter != metric_map_.end());
- PrintResult(metric_basename_, metric_suffix, story_name_, value,
- iter->second.units, iter->second.important);
+ PrintResult(metric_basename_, metric_suffix, story_name_, value, iter->second.units,
+ iter->second.important);
}
-void PerfResultReporter::AddResult(const std::string& metric_suffix,
- const std::string& value) {
- auto iter = metric_map_.find(metric_suffix);
- CHECK(iter != metric_map_.end());
+void PerfResultReporter::AddResult(const std::string &metric_suffix, const std::string &value)
+{
+ auto iter = metric_map_.find(metric_suffix);
+ CHECK(iter != metric_map_.end());
- PrintResult(metric_basename_, metric_suffix, story_name_, value,
- iter->second.units, iter->second.important);
+ PrintResult(metric_basename_, metric_suffix, story_name_, value, iter->second.units,
+ iter->second.important);
}
-bool PerfResultReporter::GetMetricInfo(const std::string& metric_suffix,
- MetricInfo* out) {
- auto iter = metric_map_.find(metric_suffix);
- if (iter == metric_map_.end()) {
- return false;
- }
+bool PerfResultReporter::GetMetricInfo(const std::string &metric_suffix, MetricInfo *out)
+{
+ auto iter = metric_map_.find(metric_suffix);
+ if (iter == metric_map_.end())
+ {
+ return false;
+ }
- *out = iter->second;
- return true;
+ *out = iter->second;
+ return true;
}
-void PerfResultReporter::RegisterMetric(const std::string& metric_suffix,
- const std::string& units,
- bool important) {
- CHECK(metric_map_.count(metric_suffix) == 0);
- metric_map_.insert({metric_suffix, {units, important}});
+void PerfResultReporter::RegisterMetric(const std::string &metric_suffix,
+ const std::string &units,
+ bool important)
+{
+ CHECK(metric_map_.count(metric_suffix) == 0);
+ metric_map_.insert({metric_suffix, {units, important}});
}
} // namespace perf_test
diff --git a/src/tests/perf_tests/third_party/perf/perf_result_reporter.h b/src/tests/perf_tests/third_party/perf/perf_result_reporter.h
index 3188d90c9..2620eab3d 100644
--- a/src/tests/perf_tests/third_party/perf/perf_result_reporter.h
+++ b/src/tests/perf_tests/third_party/perf/perf_result_reporter.h
@@ -8,11 +8,13 @@
#include <string>
#include <unordered_map>
-namespace perf_test {
+namespace perf_test
+{
-struct MetricInfo {
- std::string units;
- bool important;
+struct MetricInfo
+{
+ std::string units;
+ bool important;
};
// A helper class for using the perf test printing functions safely, as
@@ -32,32 +34,28 @@ struct MetricInfo {
// a single "100_chars" story. If an additional story run is added, e.g.
// "200_chars", then the metrics will be averaged over both runs with the
// ability to drill down into results for specific stories.
-class PerfResultReporter {
- public:
- PerfResultReporter(const std::string& metric_basename,
- const std::string& story_name);
- ~PerfResultReporter();
-
- void RegisterFyiMetric(const std::string& metric_suffix,
- const std::string& units);
- void RegisterImportantMetric(const std::string& metric_suffix,
- const std::string& units);
- void AddResult(const std::string& metric_suffix, size_t value);
- void AddResult(const std::string& metric_suffix, double value);
- void AddResult(const std::string& metric_suffix, const std::string& value);
-
- // Returns true and fills the pointer if the metric is registered, otherwise
- // returns false.
- bool GetMetricInfo(const std::string& metric_suffix, MetricInfo* out);
-
- private:
- void RegisterMetric(const std::string& metric_suffix,
- const std::string& units,
- bool important);
-
- std::string metric_basename_;
- std::string story_name_;
- std::unordered_map<std::string, MetricInfo> metric_map_;
+class PerfResultReporter
+{
+ public:
+ PerfResultReporter(const std::string &metric_basename, const std::string &story_name);
+ ~PerfResultReporter();
+
+ void RegisterFyiMetric(const std::string &metric_suffix, const std::string &units);
+ void RegisterImportantMetric(const std::string &metric_suffix, const std::string &units);
+ void AddResult(const std::string &metric_suffix, size_t value);
+ void AddResult(const std::string &metric_suffix, double value);
+ void AddResult(const std::string &metric_suffix, const std::string &value);
+
+ // Returns true and fills the pointer if the metric is registered, otherwise
+ // returns false.
+ bool GetMetricInfo(const std::string &metric_suffix, MetricInfo *out);
+
+ private:
+ void RegisterMetric(const std::string &metric_suffix, const std::string &units, bool important);
+
+ std::string metric_basename_;
+ std::string story_name_;
+ std::unordered_map<std::string, MetricInfo> metric_map_;
};
} // namespace perf_test
diff --git a/src/tests/perf_tests/third_party/perf/perf_test.cc b/src/tests/perf_tests/third_party/perf/perf_test.cc
index 0b0b666db..1131faf27 100644
--- a/src/tests/perf_tests/third_party/perf/perf_test.cc
+++ b/src/tests/perf_tests/third_party/perf/perf_test.cc
@@ -2,16 +2,49 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "testing/perf/perf_test.h"
+#include "perf_test.h"
+#include <stdarg.h>
#include <stdio.h>
-
-#include "base/logging.h"
-#include "base/strings/string_number_conversions.h"
-#include "base/strings/stringprintf.h"
+#include <stdarg.h>
+#include <vector>
namespace {
+namespace base {
+
+std::string FormatString(const char *fmt, va_list vararg) {
+ static std::vector<char> buffer(512);
+
......@@ -46,16 +429,223 @@ index 0d5abc0..7364330 100644
+ return result;
+}
+
+std::string UintToString(unsigned int value) {
+ return StringPrintf("%u", value);
+}
+
+std::string DoubleToString(double value) {
+ return StringPrintf("%.10lf", value);
+std::string NumberToString(size_t value)
+{
+ return StringPrintf("%u", value);
+}
+
+std::string NumberToString(double value)
+{
+ return StringPrintf("%.10lf", value);
+}
+
std::string ResultsToString(const std::string& measurement,
const std::string& modifier,
const std::string& trace,
@@ -23,10 +56,9 @@ std::string ResultsToString(const std::string& measurement,
// <*>RESULT <graph_name>: <trace_name>= <value> <units>
// <*>RESULT <graph_name>: <trace_name>= {<mean>, <std deviation>} <units>
// <*>RESULT <graph_name>: <trace_name>= [<value>,value,value,...,] <units>
- return base::StringPrintf("%sRESULT %s%s: %s= %s%s%s %s\n",
- important ? "*" : "", measurement.c_str(), modifier.c_str(),
- trace.c_str(), prefix.c_str(), values.c_str(), suffix.c_str(),
- units.c_str());
+ return StringPrintf("%sRESULT %s%s: %s= %s%s%s %s\n", important ? "*" : "", measurement.c_str(),
+ modifier.c_str(), trace.c_str(), prefix.c_str(), values.c_str(),
+ suffix.c_str(), units.c_str());
}
void PrintResultsImpl(const std::string& measurement,
@@ -53,8 +85,8 @@ void PrintResult(const std::string& measurement,
size_t value,
const std::string& units,
bool important) {
- PrintResultsImpl(measurement, modifier, trace, base::NumberToString(value),
- std::string(), std::string(), units, important);
+ PrintResultsImpl(measurement, modifier, trace, NumberToString(value), std::string(),
+ std::string(), units, important);
}
void PrintResult(const std::string& measurement,
@@ -63,8 +95,8 @@ void PrintResult(const std::string& measurement,
double value,
const std::string& units,
bool important) {
- PrintResultsImpl(measurement, modifier, trace, base::NumberToString(value),
- std::string(), std::string(), units, important);
+ PrintResultsImpl(measurement, modifier, trace, NumberToString(value), std::string(),
+ std::string(), units, important);
}
void AppendResult(std::string& output,
@@ -74,9 +106,8 @@ void AppendResult(std::string& output,
size_t value,
const std::string& units,
bool important) {
- output +=
- ResultsToString(measurement, modifier, trace, base::NumberToString(value),
- std::string(), std::string(), units, important);
+ output += ResultsToString(measurement, modifier, trace, NumberToString(value), std::string(),
+ std::string(), units, important);
}
void PrintResult(const std::string& measurement,
diff --git a/src/tests/perf_tests/third_party/perf/perf_test.h b/src/tests/perf_tests/third_party/perf/perf_test.h
index 36e2916c5..d269a34cf 100644
--- a/src/tests/perf_tests/third_party/perf/perf_test.h
+++ b/src/tests/perf_tests/third_party/perf/perf_test.h
@@ -7,7 +7,8 @@
#include <string>
-namespace perf_test {
+namespace perf_test
+{
// Prints numerical information to stdout in a controlled format, for
// post-processing. |measurement| is a description of the quantity being
@@ -22,94 +23,90 @@ namespace perf_test {
// produced for various builds, using the combined |measurement| + |modifier|
// string to specify a particular graph and the |trace| to identify a trace
// (i.e., data series) on that graph.
-void PrintResult(const std::string& measurement,
- const std::string& modifier,
- const std::string& trace,
+void PrintResult(const std::string &measurement,
+ const std::string &modifier,
+ const std::string &trace,
size_t value,
- const std::string& units,
+ const std::string &units,
bool important);
-void PrintResult(const std::string& measurement,
- const std::string& modifier,
- const std::string& trace,
+void PrintResult(const std::string &measurement,
+ const std::string &modifier,
+ const std::string &trace,
double value,
- const std::string& units,
+ const std::string &units,
bool important);
-void AppendResult(std::string& output,
- const std::string& measurement,
- const std::string& modifier,
- const std::string& trace,
+void AppendResult(std::string &output,
+ const std::string &measurement,
+ const std::string &modifier,
+ const std::string &trace,
size_t value,
- const std::string& units,
+ const std::string &units,
bool important);
// Like the above version of PrintResult(), but takes a std::string value
// instead of a size_t.
-void PrintResult(const std::string& measurement,
- const std::string& modifier,
- const std::string& trace,
- const std::string& value,
- const std::string& units,
+void PrintResult(const std::string &measurement,
+ const std::string &modifier,
+ const std::string &trace,
+ const std::string &value,
+ const std::string &units,
bool important);
-void AppendResult(std::string& output,
- const std::string& measurement,
- const std::string& modifier,
- const std::string& trace,
- const std::string& value,
- const std::string& units,
+void AppendResult(std::string &output,
+ const std::string &measurement,
+ const std::string &modifier,
+ const std::string &trace,
+ const std::string &value,
+ const std::string &units,
bool important);
// Like PrintResult(), but prints a (mean, standard deviation) result pair.
// The |<values>| should be two comma-separated numbers, the mean and
// standard deviation (or other error metric) of the measurement.
-void PrintResultMeanAndError(const std::string& measurement,
- const std::string& modifier,
- const std::string& trace,
- const std::string& mean_and_error,
- const std::string& units,
+void PrintResultMeanAndError(const std::string &measurement,
+ const std::string &modifier,
+ const std::string &trace,
+ const std::string &mean_and_error,
+ const std::string &units,
bool important);
-void AppendResultMeanAndError(std::string& output,
- const std::string& measurement,
- const std::string& modifier,
- const std::string& trace,
- const std::string& mean_and_error,
- const std::string& units,
+void AppendResultMeanAndError(std::string &output,
+ const std::string &measurement,
+ const std::string &modifier,
+ const std::string &trace,
+ const std::string &mean_and_error,
+ const std::string &units,
bool important);
// Like PrintResult(), but prints an entire list of results. The |values|
// will generally be a list of comma-separated numbers. A typical
// post-processing step might produce plots of their mean and standard
// deviation.
-void PrintResultList(const std::string& measurement,
- const std::string& modifier,
- const std::string& trace,
- const std::string& values,
- const std::string& units,
+void PrintResultList(const std::string &measurement,
+ const std::string &modifier,
+ const std::string &trace,
+ const std::string &values,
+ const std::string &units,
bool important);
-void AppendResultList(std::string& output,
- const std::string& measurement,
- const std::string& modifier,
- const std::string& trace,
- const std::string& values,
- const std::string& units,
+void AppendResultList(std::string &output,
+ const std::string &measurement,
+ const std::string &modifier,
+ const std::string &trace,
+ const std::string &values,
+ const std::string &units,
bool important);
// Prints memory commit charge stats for use by perf graphs.
-void PrintSystemCommitCharge(const std::string& test_name,
- size_t charge,
- bool important);
+void PrintSystemCommitCharge(const std::string &test_name, size_t charge, bool important);
-void PrintSystemCommitCharge(FILE* target,
- const std::string& test_name,
+void PrintSystemCommitCharge(FILE *target,
+ const std::string &test_name,
size_t charge,
bool important);
-std::string SystemCommitChargeToString(const std::string& test_name,
- size_t charge,
- bool important);
+std::string SystemCommitChargeToString(const std::string &test_name, size_t charge, bool important);
} // namespace perf_test
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "perf_result_reporter.h"
#include "anglebase/logging.h"
#include "perf_test.h"
namespace perf_test
{
PerfResultReporter::PerfResultReporter(const std::string &metric_basename,
const std::string &story_name)
: metric_basename_(metric_basename), story_name_(story_name)
{}
PerfResultReporter::~PerfResultReporter() = default;
void PerfResultReporter::RegisterFyiMetric(const std::string &metric_suffix,
const std::string &units)
{
RegisterMetric(metric_suffix, units, false);
}
void PerfResultReporter::RegisterImportantMetric(const std::string &metric_suffix,
const std::string &units)
{
RegisterMetric(metric_suffix, units, true);
}
void PerfResultReporter::AddResult(const std::string &metric_suffix, size_t value)
{
auto iter = metric_map_.find(metric_suffix);
CHECK(iter != metric_map_.end());
PrintResult(metric_basename_, metric_suffix, story_name_, value, iter->second.units,
iter->second.important);
}
void PerfResultReporter::AddResult(const std::string &metric_suffix, double value)
{
auto iter = metric_map_.find(metric_suffix);
CHECK(iter != metric_map_.end());
PrintResult(metric_basename_, metric_suffix, story_name_, value, iter->second.units,
iter->second.important);
}
void PerfResultReporter::AddResult(const std::string &metric_suffix, const std::string &value)
{
auto iter = metric_map_.find(metric_suffix);
CHECK(iter != metric_map_.end());
PrintResult(metric_basename_, metric_suffix, story_name_, value, iter->second.units,
iter->second.important);
}
bool PerfResultReporter::GetMetricInfo(const std::string &metric_suffix, MetricInfo *out)
{
auto iter = metric_map_.find(metric_suffix);
if (iter == metric_map_.end())
{
return false;
}
*out = iter->second;
return true;
}
void PerfResultReporter::RegisterMetric(const std::string &metric_suffix,
const std::string &units,
bool important)
{
CHECK(metric_map_.count(metric_suffix) == 0);
metric_map_.insert({metric_suffix, {units, important}});
}
} // namespace perf_test
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef TESTING_PERF_PERF_RESULT_REPORTER_H_
#define TESTING_PERF_PERF_RESULT_REPORTER_H_
#include <string>
#include <unordered_map>
namespace perf_test
{
struct MetricInfo
{
std::string units;
bool important;
};
// A helper class for using the perf test printing functions safely, as
// otherwise it's easy to accidentally mix up arguments to produce usable but
// malformed perf data. See https://crbug.com/923564.
// Sample usage:
// auto reporter = PerfResultReporter("TextRendering", "100_chars");
// reporter.RegisterImportantMetric(".wall_time", "ms");
// reporter.RegisterImportantMetric(".cpu_time", "ms");
// ...
// reporter.AddResult(".wall_time", GetWallTime());
// reporter.AddResult(".cpu_time", GetCpuTime());
// This would end up reporting "TextRendering.wall_time" and
// "TextRendering.cpu_time" metrics on the dashboard, made up of results from
// a single "100_chars" story. If an additional story run is added, e.g.
// "200_chars", then the metrics will be averaged over both runs with the
// ability to drill down into results for specific stories.
class PerfResultReporter
{
public:
PerfResultReporter(const std::string &metric_basename, const std::string &story_name);
~PerfResultReporter();
void RegisterFyiMetric(const std::string &metric_suffix, const std::string &units);
void RegisterImportantMetric(const std::string &metric_suffix, const std::string &units);
void AddResult(const std::string &metric_suffix, size_t value);
void AddResult(const std::string &metric_suffix, double value);
void AddResult(const std::string &metric_suffix, const std::string &value);
// Returns true and fills the pointer if the metric is registered, otherwise
// returns false.
bool GetMetricInfo(const std::string &metric_suffix, MetricInfo *out);
private:
void RegisterMetric(const std::string &metric_suffix, const std::string &units, bool important);
std::string metric_basename_;
std::string story_name_;
std::unordered_map<std::string, MetricInfo> metric_map_;
};
} // namespace perf_test
#endif // TESTING_PERF_PERF_RESULT_REPORTER_H_
......@@ -8,14 +8,8 @@
#include <stdio.h>
#include <vector>
#if defined(ANDROID)
# include <android/log.h>
#endif
namespace {
namespace base {
std::string FormatString(const char *fmt, va_list vararg) {
static std::vector<char> buffer(512);
......@@ -41,14 +35,14 @@ std::string StringPrintf(const char *fmt, ...) {
return result;
}
std::string UintToString(unsigned int value) {
return StringPrintf("%u", value);
}
std::string DoubleToString(double value) {
return StringPrintf("%.10lf", value);
std::string NumberToString(size_t value)
{
return StringPrintf("%u", value);
}
std::string NumberToString(double value)
{
return StringPrintf("%.10lf", value);
}
std::string ResultsToString(const std::string& measurement,
......@@ -62,10 +56,9 @@ std::string ResultsToString(const std::string& measurement,
// <*>RESULT <graph_name>: <trace_name>= <value> <units>
// <*>RESULT <graph_name>: <trace_name>= {<mean>, <std deviation>} <units>
// <*>RESULT <graph_name>: <trace_name>= [<value>,value,value,...,] <units>
return base::StringPrintf("%sRESULT %s%s: %s= %s%s%s %s\n",
important ? "*" : "", measurement.c_str(), modifier.c_str(),
trace.c_str(), prefix.c_str(), values.c_str(), suffix.c_str(),
units.c_str());
return StringPrintf("%sRESULT %s%s: %s= %s%s%s %s\n", important ? "*" : "", measurement.c_str(),
modifier.c_str(), trace.c_str(), prefix.c_str(), values.c_str(),
suffix.c_str(), units.c_str());
}
void PrintResultsImpl(const std::string& measurement,
......@@ -92,14 +85,8 @@ void PrintResult(const std::string& measurement,
size_t value,
const std::string& units,
bool important) {
PrintResultsImpl(measurement,
modifier,
trace,
base::UintToString(static_cast<unsigned int>(value)),
std::string(),
std::string(),
units,
important);
PrintResultsImpl(measurement, modifier, trace, NumberToString(value), std::string(),
std::string(), units, important);
}
void PrintResult(const std::string& measurement,
......@@ -108,14 +95,8 @@ void PrintResult(const std::string& measurement,
double value,
const std::string& units,
bool important) {
PrintResultsImpl(measurement,
modifier,
trace,
base::DoubleToString(value),
std::string(),
std::string(),
units,
important);
PrintResultsImpl(measurement, modifier, trace, NumberToString(value), std::string(),
std::string(), units, important);
}
void AppendResult(std::string& output,
......@@ -125,15 +106,8 @@ void AppendResult(std::string& output,
size_t value,
const std::string& units,
bool important) {
output += ResultsToString(
measurement,
modifier,
trace,
base::UintToString(static_cast<unsigned int>(value)),
std::string(),
std::string(),
units,
important);
output += ResultsToString(measurement, modifier, trace, NumberToString(value), std::string(),
std::string(), units, important);
}
void PrintResult(const std::string& measurement,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment