Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/angle
Path: blob/main_old/src/tests/perf_tests/ResultPerf.cpp
1693 views
1
//
2
// Copyright 2018 The ANGLE Project Authors. All rights reserved.
3
// Use of this source code is governed by a BSD-style license that can be
4
// found in the LICENSE file.
5
//
6
// ResultPerf:
7
// Performance test for ANGLE's Error result class.
8
//
9
10
#include "ANGLEPerfTest.h"
11
#include "libANGLE/Error.h"
12
13
volatile int gThing = 0;
14
15
namespace
16
{
17
constexpr int kIterationsPerStep = 1000;
18
19
class ResultPerfTest : public ANGLEPerfTest
20
{
21
public:
22
ResultPerfTest();
23
void step() override;
24
};
25
26
ResultPerfTest::ResultPerfTest() : ANGLEPerfTest("ResultPerf", "", "_run", kIterationsPerStep) {}
27
28
ANGLE_NOINLINE angle::Result ExternalCall()
29
{
30
if (gThing != 0)
31
{
32
printf("Something very slow");
33
return angle::Result::Stop;
34
}
35
else
36
{
37
return angle::Result::Continue;
38
}
39
}
40
41
angle::Result CallReturningResult(int depth)
42
{
43
ANGLE_TRY(ExternalCall());
44
ANGLE_TRY(ExternalCall());
45
ANGLE_TRY(ExternalCall());
46
ANGLE_TRY(ExternalCall());
47
ANGLE_TRY(ExternalCall());
48
ANGLE_TRY(ExternalCall());
49
ANGLE_TRY(ExternalCall());
50
ANGLE_TRY(ExternalCall());
51
ANGLE_TRY(ExternalCall());
52
return ExternalCall();
53
}
54
55
void ResultPerfTest::step()
56
{
57
for (int i = 0; i < kIterationsPerStep; i++)
58
{
59
(void)CallReturningResult(0);
60
(void)CallReturningResult(0);
61
(void)CallReturningResult(0);
62
(void)CallReturningResult(0);
63
(void)CallReturningResult(0);
64
}
65
}
66
67
TEST_F(ResultPerfTest, Run)
68
{
69
run();
70
}
71
} // anonymous namespace
72
73