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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 static SkTArray<SkString> gFailures; | 74 static SkTArray<SkString> gFailures; |
75 | 75 |
76 static void fail(const SkString& err) { | 76 static void fail(const SkString& err) { |
77 SkAutoMutexAcquire lock(gFailuresMutex); | 77 SkAutoMutexAcquire lock(gFailuresMutex); |
78 SkDebugf("\n\nFAILURE: %s\n\n", err.c_str()); | 78 SkDebugf("\n\nFAILURE: %s\n\n", err.c_str()); |
79 gFailures.push_back(err); | 79 gFailures.push_back(err); |
80 } | 80 } |
81 | 81 |
82 | 82 |
83 // We use a spinlock to make locking this in a signal handler _somewhat_ safe. | 83 // We use a spinlock to make locking this in a signal handler _somewhat_ safe. |
84 SK_DECLARE_STATIC_SPINLOCK(gMutex); | 84 static SkSpinlock gMutex; |
85 static int32_t gPending; | 85 static int32_t gPending; |
86 static SkTArray<SkString> gRunning; | 86 static SkTArray<SkString> gRunning; |
87 | 87 |
88 static void done(const char* config, const char* src, const char* srcOptions, co
nst char* name) { | 88 static void done(const char* config, const char* src, const char* srcOptions, co
nst char* name) { |
89 SkString id = SkStringPrintf("%s %s %s %s", config, src, srcOptions, name); | 89 SkString id = SkStringPrintf("%s %s %s %s", config, src, srcOptions, name); |
90 int pending; | 90 int pending; |
91 { | 91 { |
92 SkAutoTAcquire<SkPODSpinlock> lock(gMutex); | 92 SkAutoTAcquire<SkSpinlock> lock(gMutex); |
93 for (int i = 0; i < gRunning.count(); i++) { | 93 for (int i = 0; i < gRunning.count(); i++) { |
94 if (gRunning[i] == id) { | 94 if (gRunning[i] == id) { |
95 gRunning.removeShuffle(i); | 95 gRunning.removeShuffle(i); |
96 break; | 96 break; |
97 } | 97 } |
98 } | 98 } |
99 pending = --gPending; | 99 pending = --gPending; |
100 } | 100 } |
101 // We write our dm.json file every once in a while in case we crash. | 101 // We write our dm.json file every once in a while in case we crash. |
102 // Notice this also handles the final dm.json when pending == 0. | 102 // Notice this also handles the final dm.json when pending == 0. |
103 if (pending % 500 == 0) { | 103 if (pending % 500 == 0) { |
104 JsonWriter::DumpJson(); | 104 JsonWriter::DumpJson(); |
105 } | 105 } |
106 } | 106 } |
107 | 107 |
108 static void start(const char* config, const char* src, const char* srcOptions, c
onst char* name) { | 108 static void start(const char* config, const char* src, const char* srcOptions, c
onst char* name) { |
109 SkString id = SkStringPrintf("%s %s %s %s", config, src, srcOptions, name); | 109 SkString id = SkStringPrintf("%s %s %s %s", config, src, srcOptions, name); |
110 SkAutoTAcquire<SkPODSpinlock> lock(gMutex); | 110 SkAutoTAcquire<SkSpinlock> lock(gMutex); |
111 gRunning.push_back(id); | 111 gRunning.push_back(id); |
112 } | 112 } |
113 | 113 |
114 static void print_status() { | 114 static void print_status() { |
115 static SkMSec start_ms = SkTime::GetMSecs(); | 115 static SkMSec start_ms = SkTime::GetMSecs(); |
116 | 116 |
117 int curr = sk_tools::getCurrResidentSetSizeMB(), | 117 int curr = sk_tools::getCurrResidentSetSizeMB(), |
118 peak = sk_tools::getMaxResidentSetSizeMB(); | 118 peak = sk_tools::getMaxResidentSetSizeMB(); |
119 SkString elapsed = HumanizeMs(SkTime::GetMSecs() - start_ms); | 119 SkString elapsed = HumanizeMs(SkTime::GetMSecs() - start_ms); |
120 | 120 |
121 SkAutoTAcquire<SkPODSpinlock> lock(gMutex); | 121 SkAutoTAcquire<SkSpinlock> lock(gMutex); |
122 SkDebugf("\n%s elapsed, %d active, %d queued, %dMB RAM, %dMB peak\n", | 122 SkDebugf("\n%s elapsed, %d active, %d queued, %dMB RAM, %dMB peak\n", |
123 elapsed.c_str(), gRunning.count(), gPending - gRunning.count(), cur
r, peak); | 123 elapsed.c_str(), gRunning.count(), gPending - gRunning.count(), cur
r, peak); |
124 for (auto& task : gRunning) { | 124 for (auto& task : gRunning) { |
125 SkDebugf("\t%s\n", task.c_str()); | 125 SkDebugf("\t%s\n", task.c_str()); |
126 } | 126 } |
127 } | 127 } |
128 | 128 |
129 #if defined(SK_BUILD_FOR_WIN32) | 129 #if defined(SK_BUILD_FOR_WIN32) |
130 static void setup_crash_handler() { | 130 static void setup_crash_handler() { |
131 // TODO: custom crash handler like below to print out what was running | 131 // TODO: custom crash handler like below to print out what was running |
(...skipping 1010 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1142 | 1142 |
1143 // Kick off as much parallel work as we can, making note of any serial work
we'll need to do. | 1143 // Kick off as much parallel work as we can, making note of any serial work
we'll need to do. |
1144 SkTaskGroup parallel; | 1144 SkTaskGroup parallel; |
1145 SkTArray<Task> serial; | 1145 SkTArray<Task> serial; |
1146 | 1146 |
1147 for (auto& sink : gSinks) | 1147 for (auto& sink : gSinks) |
1148 for (auto& src : gSrcs) { | 1148 for (auto& src : gSrcs) { |
1149 if (src->veto(sink->flags()) || | 1149 if (src->veto(sink->flags()) || |
1150 is_blacklisted(sink.tag.c_str(), src.tag.c_str(), | 1150 is_blacklisted(sink.tag.c_str(), src.tag.c_str(), |
1151 src.options.c_str(), src->name().c_str())) { | 1151 src.options.c_str(), src->name().c_str())) { |
1152 SkAutoTAcquire<SkPODSpinlock> lock(gMutex); | 1152 SkAutoTAcquire<SkSpinlock> lock(gMutex); |
1153 gPending--; | 1153 gPending--; |
1154 continue; | 1154 continue; |
1155 } | 1155 } |
1156 | 1156 |
1157 Task task(src, sink); | 1157 Task task(src, sink); |
1158 if (src->serial() || sink->serial()) { | 1158 if (src->serial() || sink->serial()) { |
1159 serial.push_back(task); | 1159 serial.push_back(task); |
1160 } else { | 1160 } else { |
1161 parallel.add([task] { Task::Run(task); }); | 1161 parallel.add([task] { Task::Run(task); }); |
1162 } | 1162 } |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1285 Reporter* reporter, | 1285 Reporter* reporter, |
1286 GrContextFactory* fac
tory); | 1286 GrContextFactory* fac
tory); |
1287 } // namespace skiatest | 1287 } // namespace skiatest |
1288 | 1288 |
1289 #if !defined(SK_BUILD_FOR_IOS) | 1289 #if !defined(SK_BUILD_FOR_IOS) |
1290 int main(int argc, char** argv) { | 1290 int main(int argc, char** argv) { |
1291 SkCommandLineFlags::Parse(argc, argv); | 1291 SkCommandLineFlags::Parse(argc, argv); |
1292 return dm_main(); | 1292 return dm_main(); |
1293 } | 1293 } |
1294 #endif | 1294 #endif |
OLD | NEW |