From c3b05cf3988af9f7082538812b7df3b8e52fe844 Mon Sep 17 00:00:00 2001 From: Alexey Spizhevoy Date: Thu, 3 Mar 2011 13:46:44 +0000 Subject: [PATCH] added command line args parsing into gpu performance sample --- samples/gpu/performance/performance.cpp | 26 +++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/samples/gpu/performance/performance.cpp b/samples/gpu/performance/performance.cpp index c265b364e0..01623ff049 100644 --- a/samples/gpu/performance/performance.cpp +++ b/samples/gpu/performance/performance.cpp @@ -1,5 +1,6 @@ #include #include +#include #include "performance.h" using namespace std; @@ -151,12 +152,25 @@ int CV_CDECL cvErrorCallback(int /*status*/, const char* /*func_name*/, int main(int argc, char** argv) { - if (argc < 3) - cout << "Usage: performance_gpu \n\n"; - if (argc >= 2) - TestSystem::instance().setTestFilter(argv[1]); - if (argc >= 3) - TestSystem::instance().setWorkingDir(argv[2]); + // Parse command line arguments + for (int i = 1; i < argc; ++i) + { + string key = argv[i]; + if (key == "--help") + { + cout << "Usage: performance_gpu [--filter ] [--working-dir ]\n"; + return 0; + } + if (key == "--filter" && i + 1 < argc) + TestSystem::instance().setTestFilter(argv[++i]); + else if (key == "--working-dir" && i + 1 < argc) + TestSystem::instance().setWorkingDir(argv[++i]); + else + { + cout << "Unknown parameter: '" << key << "'" << endl; + return -1; + } + } redirectError(cvErrorCallback); TestSystem::instance().run();