Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1261)

Unified Diff: client/deps/glbench/src/main.cc

Issue 2794002: Added gflags switches: duration, tests, save, out. (Closed) Base URL: ssh://git@chromiumos-git//autotest.git
Patch Set: addressed comments Created 10 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « client/deps/glbench/src/fillratetest.cc ('k') | client/deps/glbench/src/readpixeltest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: client/deps/glbench/src/main.cc
diff --git a/client/deps/glbench/src/main.cc b/client/deps/glbench/src/main.cc
index d11265828bc7d9dbca72290f3e3b0a65b890e1ee..d77748105d633764db69d08a4a6d91d916db2d4c 100644
--- a/client/deps/glbench/src/main.cc
+++ b/client/deps/glbench/src/main.cc
@@ -2,60 +2,55 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include <fcntl.h>
+#include <gflags/gflags.h>
#include <stdio.h>
#include <stdlib.h>
-#include <string.h>
-#include <sys/mman.h>
#include "base/logging.h"
+#include "base/string_util.h"
#include "main.h"
#include "utils.h"
-#include "yuv2rgb.h"
#include "all_tests.h"
#include "testbase.h"
+using std::string;
+using std::vector;
-const int enabled_tests_max = 8;
-// TODO: fix enabled_tests.
-const char *enabled_tests[enabled_tests_max+1] = {NULL};
-int seconds_to_run = 0;
-
-
-// TODO: use proper command line parsing library.
-static void ParseArgs(int argc, char *argv[]) {
- const char **enabled_tests_ptr = enabled_tests;
- bool test_name_arg = false;
- bool duration_arg = false;
- for (int i = 0; i < argc; i++) {
- if (test_name_arg) {
- test_name_arg = false;
- *enabled_tests_ptr++ = argv[i];
- if (enabled_tests_ptr - enabled_tests >= enabled_tests_max)
- break;
- } else if (duration_arg) {
- duration_arg = false;
- seconds_to_run = atoi(argv[i]);
- } else if (strcmp("-t", argv[i]) == 0) {
- test_name_arg = true;
- } else if (strcmp("-d", argv[i]) == 0) {
- duration_arg = true;
- }
+DEFINE_int32(duration, 0, "run tests in a loop for at least this many seconds");
+DEFINE_string(tests, "", "colon-separated list of tests to run; "
+ "all tests if omitted");
+
+
+bool test_is_enabled(glbench::TestBase* test,
+ const vector<string>& enabled_tests) {
+ if (enabled_tests.empty())
+ return true;
+
+ const char* test_name = test->Name();
+ for (vector<string>::const_iterator i = enabled_tests.begin();
+ i != enabled_tests.end(); ++i) {
+ // This is not very precise, but will do until there's a need for something
+ // more flexible.
+ if (strstr(test_name, i->c_str()))
+ return true;
}
- *enabled_tests_ptr++ = NULL;
-}
+ return false;
+}
int main(int argc, char *argv[]) {
SetBasePathFromArgv0(argv[0], "src");
- ParseArgs(argc, argv);
+ google::ParseCommandLineFlags(&argc, &argv, true);
if (!Init()) {
printf("# Failed to initialize.\n");
return 1;
}
+ vector<string> enabled_tests;
+ SplitString(FLAGS_tests, ':', &enabled_tests);
+
glbench::TestBase* tests[] = {
glbench::GetSwapTest(),
glbench::GetClearTest(),
@@ -72,10 +67,18 @@ int main(int argc, char *argv[]) {
glbench::GetTextureUpdateTest(),
};
+ uint64_t done = GetUTime() + 1000000ULL * FLAGS_duration;
+ do {
+ for (unsigned int i = 0; i < arraysize(tests); i++) {
+ if (!test_is_enabled(tests[i], enabled_tests))
+ continue;
+ InitContext();
+ tests[i]->Run();
+ DestroyContext();
+ }
+ } while (GetUTime() < done);
+
for (unsigned int i = 0; i < arraysize(tests); i++) {
- InitContext();
- tests[i]->Run();
- DestroyContext();
delete tests[i];
tests[i] = NULL;
}
« no previous file with comments | « client/deps/glbench/src/fillratetest.cc ('k') | client/deps/glbench/src/readpixeltest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698