Commit 4e7a6a69 by Jamie Madill Committed by Commit Bot

Perf Tests: Fix trace test calibration.

The trace tests were including the startup time in their calibration calculations. Then was forcing them to always render one step. This fixes the calibration to attempt to get a more consistent measurement. The trace tests now render many more steps than they did before. It should increase the stability and decrease variance in our measurements as they will be runnnig many more frames than before. Also adds a verbose logging flag to help debugging. Noticed this bug when working on the trace test offscreen mode. Bug: angleproject:4845 Change-Id: Iff0c987008a935e7051fca34ef12f4433eb46092 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2300205Reviewed-by: 's avatarYuly Novikov <ynovikov@chromium.org> Reviewed-by: 's avatarCody Northrop <cnorthrop@google.com> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent 45f54928
...@@ -188,7 +188,7 @@ ANGLEPerfTest::ANGLEPerfTest(const std::string &name, ...@@ -188,7 +188,7 @@ ANGLEPerfTest::ANGLEPerfTest(const std::string &name,
mStory(story), mStory(story),
mGPUTimeNs(0), mGPUTimeNs(0),
mSkipTest(false), mSkipTest(false),
mStepsToRun(std::numeric_limits<unsigned int>::max()), mStepsToRun(gStepsToRunOverride),
mNumStepsPerformed(0), mNumStepsPerformed(0),
mIterationsPerStep(iterationsPerStep), mIterationsPerStep(iterationsPerStep),
mRunning(true) mRunning(true)
...@@ -217,24 +217,9 @@ void ANGLEPerfTest::run() ...@@ -217,24 +217,9 @@ void ANGLEPerfTest::run()
} }
// Calibrate to a fixed number of steps during an initial set time. // Calibrate to a fixed number of steps during an initial set time.
if (gStepsToRunOverride <= 0) if (mStepsToRun <= 0)
{ {
doRunLoop(kCalibrationRunTimeSeconds); calibrateStepsToRun();
// Scale steps down according to the time that exeeded one second.
double scale = kCalibrationRunTimeSeconds / mTimer.getElapsedTime();
mStepsToRun = static_cast<unsigned int>(static_cast<double>(mNumStepsPerformed) * scale);
// Calibration allows the perf test runner script to save some time.
if (gCalibration)
{
mReporter->AddResult(".steps", static_cast<size_t>(mStepsToRun));
return;
}
}
else
{
mStepsToRun = gStepsToRunOverride;
} }
// Check again for early exit. // Check again for early exit.
...@@ -246,11 +231,14 @@ void ANGLEPerfTest::run() ...@@ -246,11 +231,14 @@ void ANGLEPerfTest::run()
// Do another warmup run. Seems to consistently improve results. // Do another warmup run. Seems to consistently improve results.
doRunLoop(kMaximumRunTimeSeconds); doRunLoop(kMaximumRunTimeSeconds);
double totalTime = 0.0;
for (unsigned int trial = 0; trial < kNumTrials; ++trial) for (unsigned int trial = 0; trial < kNumTrials; ++trial)
{ {
doRunLoop(kMaximumRunTimeSeconds); doRunLoop(kMaximumRunTimeSeconds);
totalTime += printResults(); printResults();
if (gVerboseLogging)
{
printf("Trial %d time: %.2lf seconds.\n", trial + 1, mTimer.getElapsedTime());
}
} }
} }
...@@ -338,6 +326,45 @@ double ANGLEPerfTest::normalizedTime(size_t value) const ...@@ -338,6 +326,45 @@ double ANGLEPerfTest::normalizedTime(size_t value) const
return static_cast<double>(value) / static_cast<double>(mNumStepsPerformed); return static_cast<double>(value) / static_cast<double>(mNumStepsPerformed);
} }
void ANGLEPerfTest::calibrateStepsToRun()
{
// First do two warmup loops. There's no science to this. Two loops was experimentally helpful
// on a Windows NVIDIA setup when testing with Vulkan and native trace tests.
for (int i = 0; i < 2; ++i)
{
doRunLoop(kCalibrationRunTimeSeconds);
if (gVerboseLogging)
{
printf("Pre-calibration warm-up took %.2lf seconds.\n", mTimer.getElapsedTime());
}
}
// Now the real computation.
doRunLoop(kCalibrationRunTimeSeconds);
double elapsedTime = mTimer.getElapsedTime();
// Scale steps down according to the time that exeeded one second.
double scale = kCalibrationRunTimeSeconds / elapsedTime;
mStepsToRun = static_cast<unsigned int>(static_cast<double>(mNumStepsPerformed) * scale);
if (gVerboseLogging)
{
printf(
"Running %d steps (calibration took %.2lf seconds). Expecting trial time of %.2lf "
"seconds.\n",
mStepsToRun, elapsedTime,
mStepsToRun * (elapsedTime / static_cast<double>(mNumStepsPerformed)));
}
// Calibration allows the perf test runner script to save some time.
if (gCalibration)
{
mReporter->AddResult(".steps", static_cast<size_t>(mStepsToRun));
return;
}
}
std::string RenderTestParams::backend() const std::string RenderTestParams::backend() const
{ {
std::stringstream strstr; std::stringstream strstr;
...@@ -579,6 +606,11 @@ void ANGLERenderTest::SetUp() ...@@ -579,6 +606,11 @@ void ANGLERenderTest::SetUp()
std::string screenshotName = screenshotNameStr.str(); std::string screenshotName = screenshotNameStr.str();
saveScreenshot(screenshotName); saveScreenshot(screenshotName);
} }
if (mStepsToRun <= 0)
{
calibrateStepsToRun();
}
} }
void ANGLERenderTest::TearDown() void ANGLERenderTest::TearDown()
......
...@@ -88,6 +88,9 @@ class ANGLEPerfTest : public testing::Test, angle::NonCopyable ...@@ -88,6 +88,9 @@ class ANGLEPerfTest : public testing::Test, angle::NonCopyable
// Overriden in trace perf tests. // Overriden in trace perf tests.
virtual void saveScreenshot(const std::string &screenshotName) {} virtual void saveScreenshot(const std::string &screenshotName) {}
double printResults();
void calibrateStepsToRun();
std::string mName; std::string mName;
std::string mBackend; std::string mBackend;
std::string mStory; std::string mStory;
...@@ -95,13 +98,9 @@ class ANGLEPerfTest : public testing::Test, angle::NonCopyable ...@@ -95,13 +98,9 @@ class ANGLEPerfTest : public testing::Test, angle::NonCopyable
uint64_t mGPUTimeNs; uint64_t mGPUTimeNs;
bool mSkipTest; bool mSkipTest;
std::unique_ptr<perf_test::PerfResultReporter> mReporter; std::unique_ptr<perf_test::PerfResultReporter> mReporter;
int mStepsToRun;
private: int mNumStepsPerformed;
double printResults(); int mIterationsPerStep;
unsigned int mStepsToRun;
unsigned int mNumStepsPerformed;
unsigned int mIterationsPerStep;
bool mRunning; bool mRunning;
}; };
......
...@@ -18,6 +18,7 @@ int gStepsToRunOverride = -1; ...@@ -18,6 +18,7 @@ int gStepsToRunOverride = -1;
bool gEnableTrace = false; bool gEnableTrace = false;
const char *gTraceFile = "ANGLETrace.json"; const char *gTraceFile = "ANGLETrace.json";
const char *gScreenShotDir = nullptr; const char *gScreenShotDir = nullptr;
bool gVerboseLogging = false;
} // namespace angle } // namespace angle
using namespace angle; using namespace angle;
...@@ -61,6 +62,10 @@ void ANGLEProcessPerfTestArgs(int *argc, char **argv) ...@@ -61,6 +62,10 @@ void ANGLEProcessPerfTestArgs(int *argc, char **argv)
gScreenShotDir = argv[argIndex + 1]; gScreenShotDir = argv[argIndex + 1];
argIndex++; argIndex++;
} }
else if (strcmp("--verbose-logging", argv[argIndex]) == 0)
{
gVerboseLogging = true;
}
else else
{ {
argv[argcOutCount++] = argv[argIndex]; argv[argcOutCount++] = argv[argIndex];
......
...@@ -19,6 +19,7 @@ extern int gStepsToRunOverride; ...@@ -19,6 +19,7 @@ extern int gStepsToRunOverride;
extern bool gEnableTrace; extern bool gEnableTrace;
extern const char *gTraceFile; extern const char *gTraceFile;
extern const char *gScreenShotDir; extern const char *gScreenShotDir;
extern bool gVerboseLogging;
inline bool OneFrame() inline bool OneFrame()
{ {
......
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