Commit 4fef7738 by Jamie Madill Committed by Commit Bot

Add perf test for Error/Result class.

This is a performance test that stresses the Error class. It also is used in tests for the new Result class. Bug: angleproject:2575 Change-Id: Ie23c2a1ea74108d2ba72bf26f1db04e14f7eda64 Reviewed-on: https://chromium-review.googlesource.com/1077129Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent c20b950e
...@@ -236,6 +236,18 @@ std::string ToString(const T &value) ...@@ -236,6 +236,18 @@ std::string ToString(const T &value)
#define ANGLE_INLINE inline #define ANGLE_INLINE inline
#endif #endif
#if defined(__clang__) || (defined(__GNUC__) && defined(__has_attribute))
#if __has_attribute(noinline)
#define ANGLE_NOINLINE __attribute__((noinline))
#else
#define ANGLE_NOINLINE
#endif
#elif defined(_MSC_VER)
#define ANGLE_NOINLINE __declspec(noinline)
#else
#define ANGLE_NOINLINE
#endif
#ifndef ANGLE_STRINGIFY #ifndef ANGLE_STRINGIFY
#define ANGLE_STRINGIFY(x) #x #define ANGLE_STRINGIFY(x) #x
#endif #endif
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
'<(angle_path)/src/tests/perf_tests/DrawElementsPerf.cpp', '<(angle_path)/src/tests/perf_tests/DrawElementsPerf.cpp',
'<(angle_path)/src/tests/perf_tests/DynamicPromotionPerfTest.cpp', '<(angle_path)/src/tests/perf_tests/DynamicPromotionPerfTest.cpp',
'<(angle_path)/src/tests/perf_tests/EGLInitializePerf.cpp', '<(angle_path)/src/tests/perf_tests/EGLInitializePerf.cpp',
'<(angle_path)/src/tests/perf_tests/ResultPerf.cpp',
'<(angle_path)/src/tests/perf_tests/IndexConversionPerf.cpp', '<(angle_path)/src/tests/perf_tests/IndexConversionPerf.cpp',
'<(angle_path)/src/tests/perf_tests/InstancingPerf.cpp', '<(angle_path)/src/tests/perf_tests/InstancingPerf.cpp',
'<(angle_path)/src/tests/perf_tests/InterleavedAttributeData.cpp', '<(angle_path)/src/tests/perf_tests/InterleavedAttributeData.cpp',
......
//
// Copyright 2018 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.
//
// ResultPerf:
// Performance test for ANGLE's Error result class.
//
#include "ANGLEPerfTest.h"
#include "libANGLE/Error.h"
volatile int gThing = 0;
namespace
{
constexpr int kIterations = 1000;
class ResultPerfTest : public ANGLEPerfTest
{
public:
ResultPerfTest();
void step() override;
};
ResultPerfTest::ResultPerfTest() : ANGLEPerfTest("ResultPerf", "_run")
{
}
ANGLE_NOINLINE gl::Error ExternalCall()
{
if (gThing != 0)
{
printf("Something very slow");
return gl::Error(GL_INVALID_OPERATION);
}
else
{
return gl::NoError();
}
}
gl::Error CallReturningResult(int depth)
{
ANGLE_TRY(ExternalCall());
ANGLE_TRY(ExternalCall());
ANGLE_TRY(ExternalCall());
ANGLE_TRY(ExternalCall());
ANGLE_TRY(ExternalCall());
ANGLE_TRY(ExternalCall());
ANGLE_TRY(ExternalCall());
ANGLE_TRY(ExternalCall());
ANGLE_TRY(ExternalCall());
return ExternalCall();
}
void ResultPerfTest::step()
{
for (int i = 0; i < kIterations; i++)
{
(void)CallReturningResult(0);
(void)CallReturningResult(0);
(void)CallReturningResult(0);
(void)CallReturningResult(0);
(void)CallReturningResult(0);
}
}
TEST_F(ResultPerfTest, Run)
{
run();
}
} // anonymous namespace
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