]> git.saurik.com Git - wxWidgets.git/commitdiff
added -1 (a.k.a. --single) command line option
authorVadim Zeitlin <vadim@wxwidgets.org>
Tue, 14 Oct 2008 13:34:02 +0000 (13:34 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Tue, 14 Oct 2008 13:34:02 +0000 (13:34 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@56306 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

tests/benchmarks/bench.cpp

index c885d337edc9ab14fab216a65c6efc6529de6710..04723a65b7838182eda47be027e88f125665ab3a 100644 (file)
@@ -27,6 +27,7 @@
 // ----------------------------------------------------------------------------
 
 static const char OPTION_LIST = 'l';
 // ----------------------------------------------------------------------------
 
 static const char OPTION_LIST = 'l';
+static const char OPTION_SINGLE = '1';
 
 static const char OPTION_AVG_COUNT = 'a';
 static const char OPTION_NUM_RUNS = 'n';
 
 static const char OPTION_AVG_COUNT = 'a';
 static const char OPTION_NUM_RUNS = 'n';
@@ -124,6 +125,10 @@ void BenchApp::OnInitCmdLine(wxCmdLineParser& parser)
                      "list",
                      "list all the existing benchmarks");
 
                      "list",
                      "list all the existing benchmarks");
 
+    parser.AddSwitch(OPTION_SINGLE,
+                     "single",
+                     "run the benchmark once only");
+
     parser.AddOption(OPTION_AVG_COUNT,
                      "avg-count",
                      wxString::Format
     parser.AddOption(OPTION_AVG_COUNT,
                      "avg-count",
                      wxString::Format
@@ -180,10 +185,25 @@ bool BenchApp::OnCmdLineParsed(wxCmdLineParser& parser)
         return false;
     }
 
         return false;
     }
 
-    parser.Found(OPTION_AVG_COUNT, &m_avgCount);
-    parser.Found(OPTION_NUM_RUNS, &m_numRuns);
+    bool numRunsSpecified = false;
+    if ( parser.Found(OPTION_AVG_COUNT, &m_avgCount) )
+        numRunsSpecified = true;
+    if ( parser.Found(OPTION_NUM_RUNS, &m_numRuns) )
+        numRunsSpecified = true;
     parser.Found(OPTION_NUMERIC_PARAM, &m_numParam);
     parser.Found(OPTION_STRING_PARAM, &m_strParam);
     parser.Found(OPTION_NUMERIC_PARAM, &m_numParam);
     parser.Found(OPTION_STRING_PARAM, &m_strParam);
+    if ( parser.Found(OPTION_SINGLE) )
+    {
+        if ( numRunsSpecified )
+        {
+            wxFprintf(stderr, "Incompatible options specified.\n");
+
+            return false;
+        }
+
+        m_avgCount =
+        m_numRuns = 1;
+    }
 
     // construct sorted array for quick verification of benchmark names
     wxSortedArrayString benchmarks;
 
     // construct sorted array for quick verification of benchmark names
     wxSortedArrayString benchmarks;