• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // Copyright 2025 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 // ANGLEComputeTestCL:
7 //   Base class for ANGLEComputeTestCL performance tests
8 //
9 
10 #include "ANGLEComputeTestCL.h"
11 
12 #include "ANGLEPerfTestArgs.h"
13 #include "common/system_utils.h"
14 #include "util/shader_utils.h"
15 #include "util/test_utils.h"
16 
17 #include <string>
18 
19 using namespace angle;
20 
ANGLEComputeTestCL(const std::string & name,const RenderTestParams & testParams,const char * units)21 ANGLEComputeTestCL::ANGLEComputeTestCL(const std::string &name,
22                                        const RenderTestParams &testParams,
23                                        const char *units)
24     : ANGLEPerfTest(name,
25                     testParams.backend(),
26                     testParams.story(),
27                     OneFrame() ? 1 : testParams.iterationsPerStep,
28                     units),
29       mTestParams(testParams)
30 {
31     // Force fast tests to make sure our slowest bots don't time out.
32     if (OneFrame())
33     {
34         const_cast<RenderTestParams &>(testParams).iterationsPerStep = 1;
35     }
36 }
37 
~ANGLEComputeTestCL()38 ANGLEComputeTestCL::~ANGLEComputeTestCL() {}
39 
step()40 void ANGLEComputeTestCL::step()
41 {
42     drawBenchmark();
43 
44     // Sample system memory
45     uint64_t processMemoryUsageKB = GetProcessMemoryUsageKB();
46     if (processMemoryUsageKB)
47     {
48         mProcessMemoryUsageKBSamples.push_back(processMemoryUsageKB);
49     }
50 }
51 
SetUp()52 void ANGLEComputeTestCL::SetUp()
53 {
54     if (mSkipTest)
55     {
56         return;
57     }
58 
59     // Set a consistent CPU core affinity and high priority.
60     StabilizeCPUForBenchmarking();
61 
62     initializeBenchmark();
63     ANGLEPerfTest::SetUp();
64 }
65 
TearDown()66 void ANGLEComputeTestCL::TearDown()
67 {
68     ANGLEPerfTest::TearDown();
69 }
70 
updatePerfCounters()71 void ANGLEComputeTestCL::updatePerfCounters()
72 {
73     if (mPerfCounterInfo.empty())
74     {
75         return;
76     }
77 
78     std::vector<PerfMonitorTriplet> perfData = GetPerfMonitorTriplets();
79     ASSERT(!perfData.empty());
80 
81     for (auto &iter : mPerfCounterInfo)
82     {
83         uint32_t counter               = iter.first;
84         std::vector<GLuint64> &samples = iter.second.samples;
85         samples.push_back(perfData[counter].value);
86     }
87 }
88