• 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 gStepsToRunOverride    = -1;
18 bool gEnableTrace          = false;
19 const char *gTraceFile     = "ANGLETrace.json";
20 const char *gScreenShotDir = nullptr;
21 }  // namespace angle
22 
23 using namespace angle;
24 
ANGLEProcessPerfTestArgs(int * argc,char ** argv)25 void ANGLEProcessPerfTestArgs(int *argc, char **argv)
26 {
27     int argcOutCount = 0;
28 
29     for (int argIndex = 0; argIndex < *argc; argIndex++)
30     {
31         if (strcmp("--one-frame-only", argv[argIndex]) == 0)
32         {
33             gStepsToRunOverride = 1;
34         }
35         else if (strcmp("--enable-trace", argv[argIndex]) == 0)
36         {
37             gEnableTrace = true;
38         }
39         else if (strcmp("--trace-file", argv[argIndex]) == 0 && argIndex < *argc - 1)
40         {
41             gTraceFile = argv[argIndex + 1];
42             // Skip an additional argument.
43             argIndex++;
44         }
45         else if (strcmp("--calibration", argv[argIndex]) == 0)
46         {
47             gCalibration = true;
48         }
49         else if (strcmp("--steps", argv[argIndex]) == 0 && argIndex < *argc - 1)
50         {
51             unsigned int stepsToRun = 0;
52             std::stringstream strstr;
53             strstr << argv[argIndex + 1];
54             strstr >> stepsToRun;
55             gStepsToRunOverride = stepsToRun;
56             // Skip an additional argument.
57             argIndex++;
58         }
59         else if (strcmp("--screenshot-dir", argv[argIndex]) == 0 && argIndex < *argc - 1)
60         {
61             gScreenShotDir = argv[argIndex + 1];
62             argIndex++;
63         }
64         else
65         {
66             argv[argcOutCount++] = argv[argIndex];
67         }
68     }
69 
70     *argc = argcOutCount;
71 }
72