| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 "DMJsonWriter.h" | 9 #include "DMJsonWriter.h" |
| 10 #include "DMSrcSink.h" | 10 #include "DMSrcSink.h" |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 static SkTArray<SkString> gFailures; | 76 static SkTArray<SkString> gFailures; |
| 77 | 77 |
| 78 static void fail(ImplicitString err) { | 78 static void fail(ImplicitString err) { |
| 79 SkAutoMutexAcquire lock(gFailuresMutex); | 79 SkAutoMutexAcquire lock(gFailuresMutex); |
| 80 SkDebugf("\n\nFAILURE: %s\n\n", err.c_str()); | 80 SkDebugf("\n\nFAILURE: %s\n\n", err.c_str()); |
| 81 gFailures.push_back(err); | 81 gFailures.push_back(err); |
| 82 } | 82 } |
| 83 | 83 |
| 84 static int32_t gPending = 0; // Atomic. Total number of running and queued tas
ks. | 84 static int32_t gPending = 0; // Atomic. Total number of running and queued tas
ks. |
| 85 | 85 |
| 86 SK_DECLARE_STATIC_MUTEX(gRunningMutex); | 86 SK_DECLARE_STATIC_MUTEX(gRunningAndTallyMutex); |
| 87 static SkTArray<SkString> gRunning; | 87 static SkTArray<SkString> gRunning; |
| 88 static SkTHashMap<SkString, int> gNoteTally; |
| 88 | 89 |
| 89 static void done(double ms, | 90 static void done(double ms, |
| 90 ImplicitString config, ImplicitString src, ImplicitString srcOp
tions, | 91 ImplicitString config, ImplicitString src, ImplicitString srcOp
tions, |
| 91 ImplicitString name, ImplicitString note, ImplicitString log) { | 92 ImplicitString name, ImplicitString note, ImplicitString log) { |
| 92 SkString id = SkStringPrintf("%s %s %s %s", config.c_str(), src.c_str(), | 93 SkString id = SkStringPrintf("%s %s %s %s", config.c_str(), src.c_str(), |
| 93 srcOptions.c_str(), name.c_str()
); | 94 srcOptions.c_str(), name.c_str()
); |
| 94 { | 95 { |
| 95 SkAutoMutexAcquire lock(gRunningMutex); | 96 SkAutoMutexAcquire lock(gRunningAndTallyMutex); |
| 96 for (int i = 0; i < gRunning.count(); i++) { | 97 for (int i = 0; i < gRunning.count(); i++) { |
| 97 if (gRunning[i] == id) { | 98 if (gRunning[i] == id) { |
| 98 gRunning.removeShuffle(i); | 99 gRunning.removeShuffle(i); |
| 99 break; | 100 break; |
| 100 } | 101 } |
| 101 } | 102 } |
| 102 } | 103 if (!note.isEmpty()) { |
| 103 if (!FLAGS_verbose) { | 104 if (int* tally = gNoteTally.find(note)) { |
| 104 note = ""; | 105 *tally += 1; |
| 106 } else { |
| 107 gNoteTally.set(note, 1); |
| 108 } |
| 109 } |
| 105 } | 110 } |
| 106 if (!log.isEmpty()) { | 111 if (!log.isEmpty()) { |
| 107 log.prepend("\n"); | 112 log.prepend("\n"); |
| 108 } | 113 } |
| 109 auto pending = sk_atomic_dec(&gPending)-1; | 114 auto pending = sk_atomic_dec(&gPending)-1; |
| 110 if (!FLAGS_quiet) { | 115 if (!FLAGS_quiet && note.isEmpty()) { |
| 111 SkDebugf("%s(%4d/%-4dMB %6d) %s\t%s%s%s", FLAGS_verbose ? "\n" : kSkOver
writeLine | 116 SkDebugf("%s(%4d/%-4dMB %6d) %s\t%s%s", FLAGS_verbose ? "\n" : kSkOverwr
iteLine |
| 112 , sk_tools::getCurrResidentSetSizeMB(
) | 117 , sk_tools::getCurrResidentSetSizeMB(
) |
| 113 , sk_tools::getMaxResidentSetSizeMB() | 118 , sk_tools::getMaxResidentSetSizeMB() |
| 114 , pending | 119 , pending |
| 115 , HumanizeMs(ms).c_str() | 120 , HumanizeMs(ms).c_str() |
| 116 , id.c_str() | 121 , id.c_str() |
| 117 , note.c_str() | |
| 118 , log.c_str()); | 122 , log.c_str()); |
| 119 } | 123 } |
| 120 // We write our dm.json file every once in a while in case we crash. | 124 // We write our dm.json file every once in a while in case we crash. |
| 121 // Notice this also handles the final dm.json when pending == 0. | 125 // Notice this also handles the final dm.json when pending == 0. |
| 122 if (pending % 500 == 0) { | 126 if (pending % 500 == 0) { |
| 123 JsonWriter::DumpJson(); | 127 JsonWriter::DumpJson(); |
| 124 } | 128 } |
| 125 } | 129 } |
| 126 | 130 |
| 127 static void start(ImplicitString config, ImplicitString src, | 131 static void start(ImplicitString config, ImplicitString src, |
| 128 ImplicitString srcOptions, ImplicitString name) { | 132 ImplicitString srcOptions, ImplicitString name) { |
| 129 SkString id = SkStringPrintf("%s %s %s %s", config.c_str(), src.c_str(), | 133 SkString id = SkStringPrintf("%s %s %s %s", config.c_str(), src.c_str(), |
| 130 srcOptions.c_str(), name.c_str()
); | 134 srcOptions.c_str(), name.c_str()
); |
| 131 SkAutoMutexAcquire lock(gRunningMutex); | 135 SkAutoMutexAcquire lock(gRunningAndTallyMutex); |
| 132 gRunning.push_back(id); | 136 gRunning.push_back(id); |
| 133 } | 137 } |
| 134 | 138 |
| 135 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~*/ | 139 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~*/ |
| 136 | 140 |
| 137 struct Gold : public SkString { | 141 struct Gold : public SkString { |
| 138 Gold() : SkString("") {} | 142 Gold() : SkString("") {} |
| 139 Gold(ImplicitString sink, ImplicitString src, ImplicitString srcOptions, | 143 Gold(ImplicitString sink, ImplicitString src, ImplicitString srcOptions, |
| 140 ImplicitString name, ImplicitString md5) | 144 ImplicitString name, ImplicitString md5) |
| 141 : SkString("") { | 145 : SkString("") { |
| (...skipping 892 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1034 static void forever(void*) { | 1038 static void forever(void*) { |
| 1035 for (;;) { | 1039 for (;;) { |
| 1036 static const int kSec = 300; | 1040 static const int kSec = 300; |
| 1037 #if defined(SK_BUILD_FOR_WIN) | 1041 #if defined(SK_BUILD_FOR_WIN) |
| 1038 Sleep(kSec * 1000); | 1042 Sleep(kSec * 1000); |
| 1039 #else | 1043 #else |
| 1040 sleep(kSec); | 1044 sleep(kSec); |
| 1041 #endif | 1045 #endif |
| 1042 SkString running; | 1046 SkString running; |
| 1043 { | 1047 { |
| 1044 SkAutoMutexAcquire lock(gRunningMutex); | 1048 SkAutoMutexAcquire lock(gRunningAndTallyMutex); |
| 1045 for (int i = 0; i < gRunning.count(); i++) { | 1049 for (int i = 0; i < gRunning.count(); i++) { |
| 1046 running.appendf("\n\t%s", gRunning[i].c_str()); | 1050 running.appendf("\n\t%s", gRunning[i].c_str()); |
| 1047 } | 1051 } |
| 1048 } | 1052 } |
| 1049 SkDebugf("\nCurrently running:%s\n", running.c_str()); | 1053 SkDebugf("\nCurrently running:%s\n", running.c_str()); |
| 1050 } | 1054 } |
| 1051 } | 1055 } |
| 1052 }; | 1056 }; |
| 1053 static SkThread* intentionallyLeaked = new SkThread(Loop::forever); | 1057 static SkThread* intentionallyLeaked = new SkThread(Loop::forever); |
| 1054 intentionallyLeaked->start(); | 1058 intentionallyLeaked->start(); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1111 break; | 1115 break; |
| 1112 default: | 1116 default: |
| 1113 tg.add(run_enclave, &enclaves[i]); | 1117 tg.add(run_enclave, &enclaves[i]); |
| 1114 break; | 1118 break; |
| 1115 } | 1119 } |
| 1116 } | 1120 } |
| 1117 tg.wait(); | 1121 tg.wait(); |
| 1118 // At this point we're back in single-threaded land. | 1122 // At this point we're back in single-threaded land. |
| 1119 sk_tool_utils::release_portable_typefaces(); | 1123 sk_tool_utils::release_portable_typefaces(); |
| 1120 | 1124 |
| 1125 if (FLAGS_verbose && gNoteTally.count() > 0) { |
| 1126 SkDebugf("\nNote tally:\n"); |
| 1127 gNoteTally.foreach([](const SkString& note, int* tally) { |
| 1128 SkDebugf("%dx\t%s\n", *tally, note.c_str()); |
| 1129 }); |
| 1130 } |
| 1131 |
| 1121 SkDebugf("\n"); | 1132 SkDebugf("\n"); |
| 1122 if (gFailures.count() > 0) { | 1133 if (gFailures.count() > 0) { |
| 1123 SkDebugf("Failures:\n"); | 1134 SkDebugf("Failures:\n"); |
| 1124 for (int i = 0; i < gFailures.count(); i++) { | 1135 for (int i = 0; i < gFailures.count(); i++) { |
| 1125 SkDebugf("\t%s\n", gFailures[i].c_str()); | 1136 SkDebugf("\t%s\n", gFailures[i].c_str()); |
| 1126 } | 1137 } |
| 1127 SkDebugf("%d failures\n", gFailures.count()); | 1138 SkDebugf("%d failures\n", gFailures.count()); |
| 1128 return 1; | 1139 return 1; |
| 1129 } | 1140 } |
| 1130 if (gPending > 0) { | 1141 if (gPending > 0) { |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1197 Reporter* reporter, | 1208 Reporter* reporter, |
| 1198 GrContextFactory* fac
tory); | 1209 GrContextFactory* fac
tory); |
| 1199 } // namespace skiatest | 1210 } // namespace skiatest |
| 1200 | 1211 |
| 1201 #if !defined(SK_BUILD_FOR_IOS) | 1212 #if !defined(SK_BUILD_FOR_IOS) |
| 1202 int main(int argc, char** argv) { | 1213 int main(int argc, char** argv) { |
| 1203 SkCommandLineFlags::Parse(argc, argv); | 1214 SkCommandLineFlags::Parse(argc, argv); |
| 1204 return dm_main(); | 1215 return dm_main(); |
| 1205 } | 1216 } |
| 1206 #endif | 1217 #endif |
| OLD | NEW |