• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // Copyright 2019 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 // ANGLEPerfTestArgs.cpp:
7 //   Parse command line arguments for angle_perftests.
8 //
9 
10 #include "ANGLEPerfTestArgs.h"
11 #include <string.h>
12 #include <sstream>
13 
14 namespace angle
15 {
16 bool gCalibration              = false;
17 int gStepsPerTrial             = 0;
18 int gMaxStepsPerformed         = 0;
19 bool gEnableTrace              = false;
20 const char *gTraceFile         = "ANGLETrace.json";
21 const char *gScreenShotDir     = nullptr;
22 int gScreenShotFrame           = 1;
23 bool gVerboseLogging           = false;
24 double gCalibrationTimeSeconds = 1.0;
25 double gMaxTrialTimeSeconds    = 10.0;
26 int gTestTrials                = 3;
27 bool gNoFinish                 = false;
28 bool gEnableAllTraceTests      = false;
29 bool gRetraceMode              = false;
30 bool gMinimizeGPUWork          = false;
31 
32 // Default to three warmup loops. There's no science to this. More than two loops was experimentally
33 // helpful on a Windows NVIDIA setup when testing with Vulkan and native trace tests.
34 int gWarmupLoops = 3;
35 }  // namespace angle
36 
37 namespace
38 {
ReadIntArgument(const char * arg)39 int ReadIntArgument(const char *arg)
40 {
41     std::stringstream strstr;
42     strstr << arg;
43 
44     int value;
45     strstr >> value;
46     return value;
47 }
48 
49 // The same as --screenshot-dir, but used by Chrome tests.
50 constexpr char kRenderTestDirArg[] = "--render-test-output-dir=";
51 }  // namespace
52 
53 using namespace angle;
54 
ANGLEProcessPerfTestArgs(int * argc,char ** argv)55 void ANGLEProcessPerfTestArgs(int *argc, char **argv)
56 {
57     for (int argIndex = 0; argIndex < *argc; argIndex++)
58     {
59         if (strcmp("--one-frame-only", argv[argIndex]) == 0)
60         {
61             gStepsPerTrial = 1;
62             gWarmupLoops   = 0;
63         }
64         else if (strcmp("--enable-trace", argv[argIndex]) == 0)
65         {
66             gEnableTrace = true;
67         }
68         else if (strcmp("--trace-file", argv[argIndex]) == 0 && argIndex < *argc - 1)
69         {
70             gTraceFile = argv[argIndex + 1];
71             // Skip an additional argument.
72             argIndex++;
73         }
74         else if (strcmp("--calibration", argv[argIndex]) == 0)
75         {
76             gCalibration = true;
77             gTestTrials  = 0;
78         }
79         else if (strcmp("--steps-per-trial", argv[argIndex]) == 0 && argIndex < *argc - 1)
80         {
81             gStepsPerTrial = ReadIntArgument(argv[argIndex + 1]);
82             // Skip an additional argument.
83             argIndex++;
84         }
85         else if (strcmp("--max-steps-performed", argv[argIndex]) == 0 && argIndex < *argc - 1)
86         {
87             gMaxStepsPerformed   = ReadIntArgument(argv[argIndex + 1]);
88             gWarmupLoops         = 0;
89             gTestTrials          = 1;
90             gMaxTrialTimeSeconds = 36000;
91             // Skip an additional argument.
92             argIndex++;
93         }
94         else if (strcmp("--fixed-test-time", argv[argIndex]) == 0 && argIndex < *argc - 1)
95         {
96             gMaxTrialTimeSeconds = ReadIntArgument(argv[argIndex + 1]);
97             gStepsPerTrial       = std::numeric_limits<int>::max();
98             gTestTrials          = 1;
99             gWarmupLoops         = 0;
100             // Skip an additional argument.
101             argIndex++;
102         }
103         else if (strcmp("--screenshot-dir", argv[argIndex]) == 0 && argIndex < *argc - 1)
104         {
105             gScreenShotDir = argv[argIndex + 1];
106             argIndex++;
107         }
108         else if (strcmp("--screenshot-frame", argv[argIndex]) == 0 && argIndex < *argc - 1)
109         {
110             gScreenShotFrame = ReadIntArgument(argv[argIndex + 1]);
111             argIndex++;
112         }
113         else if (strcmp("--verbose-logging", argv[argIndex]) == 0 ||
114                  strcmp("--verbose", argv[argIndex]) == 0 || strcmp("-v", argv[argIndex]) == 0)
115         {
116             gVerboseLogging = true;
117         }
118         else if (strcmp("--warmup-loops", argv[argIndex]) == 0)
119         {
120             gWarmupLoops = ReadIntArgument(argv[argIndex + 1]);
121             // Skip an additional argument.
122             argIndex++;
123         }
124         else if (strcmp("--no-warmup", argv[argIndex]) == 0)
125         {
126             gWarmupLoops = 0;
127         }
128         else if (strncmp(kRenderTestDirArg, argv[argIndex], strlen(kRenderTestDirArg)) == 0)
129         {
130             gScreenShotDir = argv[argIndex] + strlen(kRenderTestDirArg);
131         }
132         else if (strcmp("--calibration-time", argv[argIndex]) == 0)
133         {
134             gCalibrationTimeSeconds = ReadIntArgument(argv[argIndex + 1]);
135             // Skip an additional argument.
136             argIndex++;
137         }
138         else if (strcmp("--max-trial-time", argv[argIndex]) == 0)
139         {
140             gMaxTrialTimeSeconds = ReadIntArgument(argv[argIndex + 1]);
141             // Skip an additional argument.
142             argIndex++;
143         }
144         else if (strcmp("--trials", argv[argIndex]) == 0)
145         {
146             gTestTrials = ReadIntArgument(argv[argIndex + 1]);
147             // Skip an additional argument.
148             argIndex++;
149         }
150         else if (strcmp("--no-finish", argv[argIndex]) == 0)
151         {
152             gNoFinish = true;
153         }
154         else if (strcmp("--enable-all-trace-tests", argv[argIndex]) == 0)
155         {
156             gEnableAllTraceTests = true;
157         }
158         else if (strcmp("--retrace-mode", argv[argIndex]) == 0)
159         {
160             gRetraceMode = true;
161         }
162         else if (strcmp("--minimize-gpu-work", argv[argIndex]) == 0)
163         {
164             gMinimizeGPUWork = true;
165         }
166     }
167 }
168