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

Unified Diff: client/deps/glbench/src/testbase.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/testbase.h ('k') | client/deps/glbench/src/textureupdatetest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: client/deps/glbench/src/testbase.cc
diff --git a/client/deps/glbench/src/testbase.cc b/client/deps/glbench/src/testbase.cc
index d200266c2893e772ae77e302f363f929b699fa6e..37af73fc98f70640f20dd06c95dc109d670871b9 100644
--- a/client/deps/glbench/src/testbase.cc
+++ b/client/deps/glbench/src/testbase.cc
@@ -2,9 +2,17 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include <gflags/gflags.h>
#include <stdio.h>
+#include "base/scoped_ptr.h"
+#include "base/file_util.h"
+
#include "testbase.h"
+#include "utils.h"
+
+DEFINE_bool(save, false, "save images after each test case");
+DEFINE_string(out, "out", "directory to save images");
namespace glbench {
@@ -62,7 +70,18 @@ bool Bench(TestBase* test, float *slope, int64_t *bias) {
return true;
}
-void RunTest(TestBase* test, const char *name,
+void SaveImage(const char* name) {
+ const int size = g_width * g_height * 4;
+ scoped_array<char> pixels(new char[size]);
+ glReadPixels(0, 0, g_width, g_height, GL_RGBA, GL_UNSIGNED_BYTE,
+ pixels.get());
+ FilePath dirname = GetBasePath().Append(FLAGS_out);
+ file_util::CreateDirectory(dirname);
+ FilePath filename = dirname.Append(name);
+ file_util::WriteFile(filename, pixels.get(), size);
+}
+
+void RunTest(TestBase* test, const char* name,
float coefficient, bool inverse) {
float slope;
int64_t bias;
@@ -74,6 +93,8 @@ void RunTest(TestBase* test, const char *name,
printf("%s: Nan\n", name);
} else {
if (Bench(test, &slope, &bias)) {
+ if (FLAGS_save)
+ SaveImage(name);
printf("%s: %g\n", name, coefficient * (inverse ? 1.f / slope : slope));
} else {
printf("# %s is too slow, returning zero.\n", name);
« no previous file with comments | « client/deps/glbench/src/testbase.h ('k') | client/deps/glbench/src/textureupdatetest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698