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

Side by Side Diff: tests/skia_test.cpp

Issue 540013002: Revert of SkThreadPool ~~> SkTaskGroup (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 3 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 unified diff | Download patch
« no previous file with comments | « tests/Test.cpp ('k') | tools/flags/SkCommonFlags.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2011 Google Inc. 2 * Copyright 2011 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "CrashHandler.h" 8 #include "CrashHandler.h"
9 #include "OverwriteLine.h" 9 #include "OverwriteLine.h"
10 #include "Resources.h" 10 #include "Resources.h"
11 #include "SkCommonFlags.h" 11 #include "SkCommonFlags.h"
12 #include "SkGraphics.h" 12 #include "SkGraphics.h"
13 #include "SkOSFile.h" 13 #include "SkOSFile.h"
14 #include "SkTArray.h" 14 #include "SkTArray.h"
15 #include "SkTaskGroup.h"
16 #include "SkTemplates.h" 15 #include "SkTemplates.h"
16 #include "SkThreadPool.h"
17 #include "SkTime.h" 17 #include "SkTime.h"
18 #include "Test.h" 18 #include "Test.h"
19 19
20 #if SK_SUPPORT_GPU 20 #if SK_SUPPORT_GPU
21 #include "GrContext.h" 21 #include "GrContext.h"
22 #include "GrContextFactory.h" 22 #include "GrContextFactory.h"
23 #endif 23 #endif
24 24
25 using namespace skiatest; 25 using namespace skiatest;
26 26
(...skipping 20 matching lines...) Expand all
47 47
48 private: 48 private:
49 const TestRegistry* fReg; 49 const TestRegistry* fReg;
50 }; 50 };
51 51
52 class DebugfReporter : public Reporter { 52 class DebugfReporter : public Reporter {
53 public: 53 public:
54 explicit DebugfReporter(int total) : fDone(0), fTotal(total) {} 54 explicit DebugfReporter(int total) : fDone(0), fTotal(total) {}
55 55
56 virtual bool allowExtendedTest() const SK_OVERRIDE { return FLAGS_extendedTe st; } 56 virtual bool allowExtendedTest() const SK_OVERRIDE { return FLAGS_extendedTe st; }
57 virtual bool allowThreaded() const SK_OVERRIDE { return !FLAGS_single; }
57 virtual bool verbose() const SK_OVERRIDE { return FLAGS_veryVerbos e; } 58 virtual bool verbose() const SK_OVERRIDE { return FLAGS_veryVerbos e; }
58 59
59 protected: 60 protected:
60 virtual void onReportFailed(const SkString& desc) SK_OVERRIDE { 61 virtual void onReportFailed(const SkString& desc) SK_OVERRIDE {
61 SkDebugf("\nFAILED: %s", desc.c_str()); 62 SkDebugf("\nFAILED: %s", desc.c_str());
62 } 63 }
63 64
64 virtual void onEnd(Test* test) SK_OVERRIDE { 65 virtual void onEnd(Test* test) SK_OVERRIDE {
65 const int done = 1 + sk_atomic_inc(&fDone); 66 const int done = 1 + sk_atomic_inc(&fDone);
66 67
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 toRun++; 168 toRun++;
168 } 169 }
169 total++; 170 total++;
170 } 171 }
171 172
172 // Now run them. 173 // Now run them.
173 iter.reset(); 174 iter.reset();
174 int32_t failCount = 0; 175 int32_t failCount = 0;
175 int skipCount = 0; 176 int skipCount = 0;
176 177
177 SkTaskGroup::Enabler enabled(FLAGS_threads); 178 SkThreadPool threadpool(FLAGS_threads);
178 SkTaskGroup cpuTests;
179 SkTArray<Test*> gpuTests; // Always passes ownership to an SkTestRunnable 179 SkTArray<Test*> gpuTests; // Always passes ownership to an SkTestRunnable
180 180
181 DebugfReporter reporter(toRun); 181 DebugfReporter reporter(toRun);
182 for (int i = 0; i < total; i++) { 182 for (int i = 0; i < total; i++) {
183 SkAutoTDelete<Test> test(iter.next(&reporter)); 183 SkAutoTDelete<Test> test(iter.next(&reporter));
184 if (!should_run(test->getName(), test->isGPUTest())) { 184 if (!should_run(test->getName(), test->isGPUTest())) {
185 ++skipCount; 185 ++skipCount;
186 } else if (test->isGPUTest()) { 186 } else if (test->isGPUTest()) {
187 gpuTests.push_back() = test.detach(); 187 gpuTests.push_back() = test.detach();
188 } else { 188 } else {
189 cpuTests.add(SkNEW_ARGS(SkTestRunnable, (test.detach(), &failCount)) ); 189 threadpool.add(SkNEW_ARGS(SkTestRunnable, (test.detach(), &failCount )));
190 } 190 }
191 } 191 }
192 192
193 #if SK_SUPPORT_GPU 193 #if SK_SUPPORT_GPU
194 // Give GPU tests a context factory if that makes sense on this machine. 194 // Give GPU tests a context factory if that makes sense on this machine.
195 GrContextFactory grContextFactory; 195 GrContextFactory grContextFactory;
196 for (int i = 0; i < gpuTests.count(); i++) { 196 for (int i = 0; i < gpuTests.count(); i++) {
197 gpuTests[i]->setGrContextFactory(&grContextFactory); 197 gpuTests[i]->setGrContextFactory(&grContextFactory);
198 } 198 }
199 #endif 199 #endif
200 200
201 // Run GPU tests on this thread. 201 // Run GPU tests on this thread.
202 for (int i = 0; i < gpuTests.count(); i++) { 202 for (int i = 0; i < gpuTests.count(); i++) {
203 SkNEW_ARGS(SkTestRunnable, (gpuTests[i], &failCount))->run(); 203 SkNEW_ARGS(SkTestRunnable, (gpuTests[i], &failCount))->run();
204 } 204 }
205 205
206 // Block until threaded tests finish. 206 // Block until threaded tests finish.
207 cpuTests.wait(); 207 threadpool.wait();
208 208
209 if (FLAGS_verbose) { 209 if (FLAGS_verbose) {
210 SkDebugf("\nFinished %d tests, %d failures, %d skipped. (%d internal tes ts)", 210 SkDebugf("\nFinished %d tests, %d failures, %d skipped. (%d internal tes ts)",
211 toRun, failCount, skipCount, reporter.countTests()); 211 toRun, failCount, skipCount, reporter.countTests());
212 } 212 }
213 SkGraphics::Term(); 213 SkGraphics::Term();
214 214
215 SkDebugf("\n"); 215 SkDebugf("\n");
216 return (failCount == 0) ? 0 : 1; 216 return (failCount == 0) ? 0 : 1;
217 } 217 }
218 218
219 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) 219 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL)
220 int main(int argc, char** argv) { 220 int main(int argc, char** argv) {
221 SkCommandLineFlags::Parse(argc, argv); 221 SkCommandLineFlags::Parse(argc, argv);
222 return test_main(); 222 return test_main();
223 } 223 }
224 #endif 224 #endif
OLDNEW
« no previous file with comments | « tests/Test.cpp ('k') | tools/flags/SkCommonFlags.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698