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

Side by Side Diff: tests/PathOpsSkpClipTest.cpp

Issue 371853005: Move threadpool code from include/utils to tools/threadpool. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: gyp Created 6 years, 5 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/PathOpsExtendedTest.cpp ('k') | tests/PathOpsThreadedCommon.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 #include "SkBitmap.h" 2 #include "SkBitmap.h"
3 #include "SkCanvas.h" 3 #include "SkCanvas.h"
4 #include "SkColor.h" 4 #include "SkColor.h"
5 #include "SkColorPriv.h" 5 #include "SkColorPriv.h"
6 #include "SkDevice.h" 6 #include "SkDevice.h"
7 #include "SkGraphics.h" 7 #include "SkGraphics.h"
8 #include "SkImageDecoder.h" 8 #include "SkImageDecoder.h"
9 #include "SkImageEncoder.h" 9 #include "SkImageEncoder.h"
10 #include "SkOSFile.h" 10 #include "SkOSFile.h"
11 #include "SkPathOpsDebug.h" 11 #include "SkPathOpsDebug.h"
12 #include "SkPicture.h" 12 #include "SkPicture.h"
13 #include "SkRTConf.h" 13 #include "SkRTConf.h"
14 #include "SkTSort.h" 14 #include "SkTSort.h"
15 #include "SkStream.h" 15 #include "SkStream.h"
16 #include "SkString.h" 16 #include "SkString.h"
17 #include "SkTArray.h" 17 #include "SkTArray.h"
18 #include "SkTDArray.h" 18 #include "SkTDArray.h"
19 #include "SkThreadPool.h" 19 #include "ThreadPool.h"
20 #include "SkTime.h" 20 #include "SkTime.h"
21 #include "Test.h" 21 #include "Test.h"
22 22
23 #ifdef SK_BUILD_FOR_WIN 23 #ifdef SK_BUILD_FOR_WIN
24 #define PATH_SLASH "\\" 24 #define PATH_SLASH "\\"
25 #define IN_DIR "D:\\skp\\slave" 25 #define IN_DIR "D:\\skp\\slave"
26 #define OUT_DIR "D:\\skpOut\\1\\" 26 #define OUT_DIR "D:\\skpOut\\1\\"
27 #else 27 #else
28 #define PATH_SLASH "/" 28 #define PATH_SLASH "/"
29 #define IN_DIR "/skp/2311328-7fc2228/slave" 29 #define IN_DIR "/skp/2311328-7fc2228/slave"
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 , fReporter(reporter) { 325 , fReporter(reporter) {
326 } 326 }
327 327
328 ~TestRunner(); 328 ~TestRunner();
329 void render(); 329 void render();
330 int fNumThreads; 330 int fNumThreads;
331 SkTDArray<class TestRunnable*> fRunnables; 331 SkTDArray<class TestRunnable*> fRunnables;
332 skiatest::Reporter* fReporter; 332 skiatest::Reporter* fReporter;
333 }; 333 };
334 334
335 class TestRunnable : public SkRunnable { 335 class TestRunnable : public Runnable {
336 public: 336 public:
337 virtual void run() SK_OVERRIDE { 337 virtual void run() SK_OVERRIDE {
338 SkGraphics::SetTLSFontCacheLimit(1 * 1024 * 1024); 338 SkGraphics::SetTLSFontCacheLimit(1 * 1024 * 1024);
339 (*fTestFun)(&fState); 339 (*fTestFun)(&fState);
340 } 340 }
341 341
342 TestState fState; 342 TestState fState;
343 void (*fTestFun)(TestState*); 343 void (*fTestFun)(TestState*);
344 }; 344 };
345 345
(...skipping 24 matching lines...) Expand all
370 } 370 }
371 }; 371 };
372 372
373 TestRunner::~TestRunner() { 373 TestRunner::~TestRunner() {
374 for (int index = 0; index < fRunnables.count(); index++) { 374 for (int index = 0; index < fRunnables.count(); index++) {
375 SkDELETE(fRunnables[index]); 375 SkDELETE(fRunnables[index]);
376 } 376 }
377 } 377 }
378 378
379 void TestRunner::render() { 379 void TestRunner::render() {
380 SkThreadPool pool(fNumThreads); 380 ThreadPool pool(fNumThreads);
381 for (int index = 0; index < fRunnables.count(); ++ index) { 381 for (int index = 0; index < fRunnables.count(); ++ index) {
382 pool.add(fRunnables[index]); 382 pool.add(fRunnables[index]);
383 } 383 }
384 } 384 }
385 385
386 //////////////////////////////////////////////// 386 ////////////////////////////////////////////////
387 387
388 static const char outOpDir[] = OUT_DIR "opClip"; 388 static const char outOpDir[] = OUT_DIR "opClip";
389 static const char outOldDir[] = OUT_DIR "oldClip"; 389 static const char outOldDir[] = OUT_DIR "oldClip";
390 static const char outSkpDir[] = OUT_DIR "skpTest"; 390 static const char outSkpDir[] = OUT_DIR "skpTest";
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after
867 if (slowest.count() > 0) { 867 if (slowest.count() > 0) {
868 SkTQSort<SortByTime>(slowest.begin(), slowest.end() - 1); 868 SkTQSort<SortByTime>(slowest.begin(), slowest.end() - 1);
869 for (int index = 0; index < slowest.count(); ++index) { 869 for (int index = 0; index < slowest.count(); ++index) {
870 const TestResult& result = *slowest[index]; 870 const TestResult& result = *slowest[index];
871 SkDebugf("%d %s time=%d\n", result.fDirNo, result.fFilename, result.fTime); 871 SkDebugf("%d %s time=%d\n", result.fDirNo, result.fFilename, result.fTime);
872 } 872 }
873 } 873 }
874 } 874 }
875 } 875 }
876 876
877 int threadCount = reporter->allowThreaded() ? SkThreadPool::kThreadPerCore : 1; 877 int threadCount = reporter->allowThreaded() ? ThreadPool::kThreadPerCore : 1 ;
878 TestRunner testRunner(reporter, threadCount); 878 TestRunner testRunner(reporter, threadCount);
879 for (int index = 0; index < state.fPixelWorst.count(); ++index) { 879 for (int index = 0; index < state.fPixelWorst.count(); ++index) {
880 const TestResult& result = state.fPixelWorst[index]; 880 const TestResult& result = state.fPixelWorst[index];
881 SkString filename(result.fFilename); 881 SkString filename(result.fFilename);
882 if (!filename.endsWith(".skp")) { 882 if (!filename.endsWith(".skp")) {
883 filename.append(".skp"); 883 filename.append(".skp");
884 } 884 }
885 *testRunner.fRunnables.append() = SkNEW_ARGS(TestRunnableEncode, 885 *testRunner.fRunnables.append() = SkNEW_ARGS(TestRunnableEncode,
886 (&testSkpClipEncode, result.fDirNo, filename.c_str(), &testRunne r)); 886 (&testSkpClipEncode, result.fDirNo, filename.c_str(), &testRunne r));
887 } 887 }
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
919 } 919 }
920 920
921 static void testSkpClipMain(TestState* data) { 921 static void testSkpClipMain(TestState* data) {
922 (void) doOneDir(data, true); 922 (void) doOneDir(data, true);
923 } 923 }
924 924
925 DEF_TEST(PathOpsSkpClipThreaded, reporter) { 925 DEF_TEST(PathOpsSkpClipThreaded, reporter) {
926 if (!initTest()) { 926 if (!initTest()) {
927 return; 927 return;
928 } 928 }
929 int threadCount = reporter->allowThreaded() ? SkThreadPool::kThreadPerCore : 1; 929 int threadCount = reporter->allowThreaded() ? ThreadPool::kThreadPerCore : 1 ;
930 TestRunner testRunner(reporter, threadCount); 930 TestRunner testRunner(reporter, threadCount);
931 const int firstDirNo = 1; 931 const int firstDirNo = 1;
932 for (int dirNo = firstDirNo; dirNo <= 100; ++dirNo) { 932 for (int dirNo = firstDirNo; dirNo <= 100; ++dirNo) {
933 *testRunner.fRunnables.append() = SkNEW_ARGS(TestRunnableDir, 933 *testRunner.fRunnables.append() = SkNEW_ARGS(TestRunnableDir,
934 (&testSkpClipMain, dirNo, &testRunner)); 934 (&testSkpClipMain, dirNo, &testRunner));
935 } 935 }
936 testRunner.render(); 936 testRunner.render();
937 TestState state; 937 TestState state;
938 state.init(0, reporter); 938 state.init(0, reporter);
939 for (int dirNo = firstDirNo; dirNo <= 100; ++dirNo) { 939 for (int dirNo = firstDirNo; dirNo <= 100; ++dirNo) {
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
1032 const int lastDirNo = 100; 1032 const int lastDirNo = 100;
1033 if (!initUberTest(firstDirNo, lastDirNo)) { 1033 if (!initUberTest(firstDirNo, lastDirNo)) {
1034 return; 1034 return;
1035 } 1035 }
1036 const int dirCount = lastDirNo - firstDirNo + 1; 1036 const int dirCount = lastDirNo - firstDirNo + 1;
1037 SkTDArray<TestResult> tests[dirCount]; 1037 SkTDArray<TestResult> tests[dirCount];
1038 SkTDArray<SortByName*> sorted[dirCount]; 1038 SkTDArray<SortByName*> sorted[dirCount];
1039 if (!buildTests(reporter, firstDirNo, lastDirNo, tests, sorted)) { 1039 if (!buildTests(reporter, firstDirNo, lastDirNo, tests, sorted)) {
1040 return; 1040 return;
1041 } 1041 }
1042 int threadCount = reporter->allowThreaded() ? SkThreadPool::kThreadPerCore : 1; 1042 int threadCount = reporter->allowThreaded() ? ThreadPool::kThreadPerCore : 1 ;
1043 TestRunner testRunner(reporter, threadCount); 1043 TestRunner testRunner(reporter, threadCount);
1044 for (int dirNo = firstDirNo; dirNo <= lastDirNo; ++dirNo) { 1044 for (int dirNo = firstDirNo; dirNo <= lastDirNo; ++dirNo) {
1045 SkString dirName = make_in_dir_name(dirNo); 1045 SkString dirName = make_in_dir_name(dirNo);
1046 if (!dirName.size()) { 1046 if (!dirName.size()) {
1047 continue; 1047 continue;
1048 } 1048 }
1049 SkOSFile::Iter iter(dirName.c_str(), "skp"); 1049 SkOSFile::Iter iter(dirName.c_str(), "skp");
1050 SkString filename; 1050 SkString filename;
1051 while (iter.next(&filename)) { 1051 while (iter.next(&filename)) {
1052 int count; 1052 int count;
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
1112 SkAssertResult(make_in_dir_name(dirNo).size()); 1112 SkAssertResult(make_in_dir_name(dirNo).size());
1113 SkString filename(skipOverSept[testIndex].filename); 1113 SkString filename(skipOverSept[testIndex].filename);
1114 TestResult state; 1114 TestResult state;
1115 state.test(dirNo, filename); 1115 state.test(dirNo, filename);
1116 if (reporter->verbose()) { 1116 if (reporter->verbose()) {
1117 SkDebugf("%s", state.status().c_str()); 1117 SkDebugf("%s", state.status().c_str());
1118 } 1118 }
1119 state.fTestStep = kEncodeFiles; 1119 state.fTestStep = kEncodeFiles;
1120 state.testOne(); 1120 state.testOne();
1121 } 1121 }
OLDNEW
« no previous file with comments | « tests/PathOpsExtendedTest.cpp ('k') | tests/PathOpsThreadedCommon.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698