chromium/third_party/angle/src/tests/perf_tests/ANGLEPerfTest.cpp

//
// Copyright 2014 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// ANGLEPerfTests:
//   Base class for google test performance tests
//

#include "ANGLEPerfTest.h"

#if defined(ANGLE_PLATFORM_ANDROID)
#    include <android/log.h>
#    include <dlfcn.h>
#endif
#include "ANGLEPerfTestArgs.h"
#include "common/base/anglebase/trace_event/trace_event.h"
#include "common/debug.h"
#include "common/gl_enum_utils.h"
#include "common/mathutil.h"
#include "common/platform.h"
#include "common/string_utils.h"
#include "common/system_utils.h"
#include "common/utilities.h"
#include "test_utils/runner/TestSuite.h"
#include "third_party/perf/perf_test.h"
#include "util/shader_utils.h"
#include "util/test_utils.h"

#include <cassert>
#include <cmath>
#include <fstream>
#include <iostream>
#include <numeric>
#include <sstream>
#include <string>

#include <rapidjson/document.h>
#include <rapidjson/filewritestream.h>
#include <rapidjson/istreamwrapper.h>
#include <rapidjson/prettywriter.h>

#if defined(ANGLE_USE_UTIL_LOADER) && defined(ANGLE_PLATFORM_WINDOWS)
#    include "util/windows/WGLWindow.h"
#endif  // defined(ANGLE_USE_UTIL_LOADER) &&defined(ANGLE_PLATFORM_WINDOWS)

usingnamespaceangle;
js;

namespace
{
constexpr size_t kInitialTraceEventBufferSize            =;
constexpr double kMilliSecondsPerSecond                  =;
constexpr double kMicroSecondsPerSecond                  =;
constexpr double kNanoSecondsPerSecond                   =;
constexpr size_t kNumberOfStepsPerformedToComputeGPUTime =;
constexpr char kPeakMemoryMetric[]                       =;
constexpr char kMedianMemoryMetric[]                     =;

struct TraceCategory
{};

constexpr TraceCategory gTraceCategories[2] =;

void EmptyPlatformMethod(PlatformMethods *, const char *) {}

void CustomLogError(PlatformMethods *platform, const char *errorMessage)
{}

TraceEventHandle AddPerfTraceEvent(PlatformMethods *platform,
                                   char phase,
                                   const unsigned char *categoryEnabledFlag,
                                   const char *name,
                                   unsigned long long id,
                                   double timestamp,
                                   int numArgs,
                                   const char **argNames,
                                   const unsigned char *argTypes,
                                   const unsigned long long *argValues,
                                   unsigned char flags)
{}

const unsigned char *GetPerfTraceCategoryEnabled(PlatformMethods *platform,
                                                 const char *categoryName)
{}

void UpdateTraceEventDuration(PlatformMethods *platform,
                              const unsigned char *categoryEnabledFlag,
                              const char *name,
                              TraceEventHandle eventHandle)
{}

double MonotonicallyIncreasingTime(PlatformMethods *platform)
{}

bool WriteJsonFile(const std::string &outputFile, js::Document *doc)
{}

void DumpTraceEventsToJSONFile(const std::vector<TraceEvent> &traceEvents,
                               const char *outputFileName)
{}

[[maybe_unused]] void KHRONOS_APIENTRY PerfTestDebugCallback(GLenum source,
                                                             GLenum type,
                                                             GLuint id,
                                                             GLenum severity,
                                                             GLsizei length,
                                                             const GLchar *message,
                                                             const void *userParam)
{}

double ComputeMean(const std::vector<double> &values)
{}

void FinishAndCheckForContextLoss()
{}

#if defined(ANGLE_PLATFORM_ANDROID)
constexpr bool kHasATrace = true;

void *gLibAndroid = nullptr;
bool (*gATraceIsEnabled)(void);
bool (*gATraceSetCounter)(const char *counterName, int64_t counterValue);

void SetupATrace()
{
    if (gLibAndroid == nullptr)
    {
        gLibAndroid       = dlopen("libandroid.so", RTLD_NOW | RTLD_LOCAL);
        gATraceIsEnabled  = (decltype(gATraceIsEnabled))dlsym(gLibAndroid, "ATrace_isEnabled");
        gATraceSetCounter = (decltype(gATraceSetCounter))dlsym(gLibAndroid, "ATrace_setCounter");
    }
}

bool ATraceEnabled()
{
    return gATraceIsEnabled();
}

void ATraceCounter(const char *counterName, int64_t counterValue)
{
    if (ATraceEnabled())
    {
        gATraceSetCounter(counterName, counterValue);
    }
}
#else
constexpr bool kHasATrace =;
void SetupATrace() {}
bool ATraceEnabled()
{}
void ATraceCounter(const char *counterName, int64_t counterValue) {}
#endif
}  // anonymous namespace

TraceEvent::TraceEvent(char phaseIn,
                       const char *categoryNameIn,
                       const char *nameIn,
                       double timestampIn,
                       uint32_t tidIn)
    :{}

ANGLEPerfTest::ANGLEPerfTest(const std::string &name,
                             const std::string &backend,
                             const std::string &story,
                             unsigned int iterationsPerStep,
                             const char *units)
    :{}

ANGLEPerfTest::~ANGLEPerfTest() {}

void ANGLEPerfTest::run()
{}

void ANGLEPerfTest::runTrial(double maxRunTime, int maxStepsToRun, RunTrialPolicy runPolicy)
{}

void ANGLEPerfTest::SetUp()
{}

void ANGLEPerfTest::TearDown() {}

void ANGLEPerfTest::recordIntegerMetric(const char *metric, size_t value, const std::string &units)
{}

void ANGLEPerfTest::recordDoubleMetric(const char *metric, double value, const std::string &units)
{}

void ANGLEPerfTest::addHistogramSample(const char *metric, double value, const std::string &units)
{}

void ANGLEPerfTest::processResults()
{}

void ANGLEPerfTest::processClockResult(const char *metric, double resultSeconds)
{}

void ANGLEPerfTest::processMemoryResult(const char *metric, uint64_t resultKB)
{}

double ANGLEPerfTest::normalizedTime(size_t value) const
{}

int ANGLEPerfTest::getStepAlignment() const
{}

RenderTestParams::RenderTestParams()
{}

std::string RenderTestParams::backend() const
{}

std::string RenderTestParams::story() const
{}

std::string RenderTestParams::backendAndStory() const
{}

ANGLERenderTest::ANGLERenderTest(const std::string &name,
                                 const RenderTestParams &testParams,
                                 const char *units)
    :{}

ANGLERenderTest::~ANGLERenderTest()
{}

void ANGLERenderTest::addExtensionPrerequisite(std::string extensionName)
{}

void ANGLERenderTest::addIntegerPrerequisite(GLenum target, int min)
{}

void ANGLERenderTest::SetUp()
{}

void ANGLERenderTest::TearDown()
{}

void ANGLERenderTest::initPerfCounters()
{}

void ANGLERenderTest::updatePerfCounters()
{}

void ANGLERenderTest::beginInternalTraceEvent(const char *name)
{}

void ANGLERenderTest::endInternalTraceEvent(const char *name)
{}

void ANGLERenderTest::beginGLTraceEvent(const char *name, double hostTimeSec)
{}

void ANGLERenderTest::endGLTraceEvent(const char *name, double hostTimeSec)
{}

void ANGLERenderTest::step()
{}

void ANGLERenderTest::startGpuTimer()
{}

void ANGLERenderTest::stopGpuTimer()
{}

void ANGLERenderTest::computeGPUTime()
{}

void ANGLERenderTest::startTest()
{}

void ANGLERenderTest::finishTest()
{}

bool ANGLERenderTest::popEvent(Event *event)
{}

OSWindow *ANGLERenderTest::getWindow()
{}

GLWindowBase *ANGLERenderTest::getGLWindow()
{}

void ANGLERenderTest::skipTestIfMissingExtensionPrerequisites()
{}

void ANGLERenderTest::skipTestIfFailsIntegerPrerequisite()
{}

void ANGLERenderTest::setWebGLCompatibilityEnabled(bool webglCompatibility)
{}

void ANGLERenderTest::setRobustResourceInit(bool enabled)
{}

std::vector<TraceEvent> &ANGLERenderTest::getTraceEventBuffer()
{}

void ANGLERenderTest::onErrorMessage(const char *errorMessage)
{}

uint32_t ANGLERenderTest::getCurrentThreadSerial()
{}

namespace angle
{
double GetHostTimeSeconds()
{}
}  // namespace angle