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

Unified Diff: tools/kilobench/kilobench.cpp

Issue 1584373002: wire this up (Closed) Base URL: https://skia.googlesource.com/skia.git@kilobench-2-setupcanvas
Patch Set: Created 4 years, 11 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 | « src/ports/SkOSFile_stdio.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/kilobench/kilobench.cpp
diff --git a/tools/kilobench/kilobench.cpp b/tools/kilobench/kilobench.cpp
index 438e582324fb2e8c97f1da061e7d9a3f8760d870..d3553f2ac604165000966c8d1f8fa2a9addb3162 100644
--- a/tools/kilobench/kilobench.cpp
+++ b/tools/kilobench/kilobench.cpp
@@ -8,6 +8,7 @@
#include "GrCaps.h"
#include "GrContextFactory.h"
#include "Benchmark.h"
+#include "ResultsWriter.h"
#include "SkCommandLineFlags.h"
#include "SkOSFile.h"
#include "SkStream.h"
@@ -18,6 +19,11 @@
#include "VisualSKPBench.h"
#include "gl/GrGLDefines.h"
+// posix only for now
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+
/*
* This is an experimental GPU only benchmarking program. The initial implementation will only
* support SKPs.
@@ -327,7 +333,12 @@ static SkString humanize(double ms) {
}
#define HUMANIZE(ms) humanize(ms).c_str()
-void benchmark_inner_loop(Benchmark* bench, GrContextFactory* ctxFactory) {
+void benchmark_inner_loop(Benchmark* bench) {
+ SkAutoTDelete<GrContextFactory> ctxFactory;
+
+ GrContextOptions grContextOpts;
+ ctxFactory.reset(new GrContextFactory(grContextOpts));
+
SkTArray<double> samples;
GPUTarget target;
SkAssertResult(target.init(bench, ctxFactory, false,
@@ -374,11 +385,6 @@ void benchmark_inner_loop(Benchmark* bench, GrContextFactory* ctxFactory) {
} // namespace kilobench
int kilobench_main() {
- SkAutoTDelete<GrContextFactory> ctxFactory;
-
- GrContextOptions grContextOpts;
- ctxFactory.reset(new GrContextFactory(grContextOpts));
-
kilobench::BenchmarkStream benchStream;
SkDebugf("loops\tmin\tmedian\tmean\tmax\tstddev\t%-*s\tconfig\tbench\n",
@@ -386,12 +392,17 @@ int kilobench_main() {
while (Benchmark* b = benchStream.next()) {
SkAutoTDelete<Benchmark> bench(b);
- kilobench::benchmark_inner_loop(bench.get(), ctxFactory.get());
- }
- // Make sure we clean up the global GrContextFactory here, otherwise we might race with the
- // SkEventTracer destructor
- ctxFactory.reset(nullptr);
+ // We fork off a new process to setup the grcontext and run the test while we wait
+ int childPid = fork();
+ if (childPid) {
+ int status;
+ waitpid(childPid, &status, 0);
+ } else {
+ kilobench::benchmark_inner_loop(bench.get());
+ return 0;
+ }
+ }
return 0;
}
« no previous file with comments | « src/ports/SkOSFile_stdio.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698