OLD | NEW |
1 #include "DMReporter.h" | 1 #include "DMReporter.h" |
2 | 2 |
| 3 #include "SkDynamicAnnotations.h" |
3 #include "SkCommandLineFlags.h" | 4 #include "SkCommandLineFlags.h" |
4 #include "OverwriteLine.h" | 5 #include "OverwriteLine.h" |
5 | 6 |
6 DEFINE_bool2(quiet, q, false, "If true, don't print status updates."); | 7 DEFINE_bool2(quiet, q, false, "If true, don't print status updates."); |
7 DEFINE_bool2(verbose, v, false, "If true, print status updates one-per-line."); | 8 DEFINE_bool2(verbose, v, false, "If true, print status updates one-per-line."); |
8 | 9 |
9 namespace DM { | 10 namespace DM { |
10 | 11 |
11 void Reporter::finish(SkString name, SkMSec timeMs) { | 12 void Reporter::printStatus(SkString name, SkMSec timeMs) const { |
12 sk_atomic_inc(&fFinished); | |
13 | |
14 if (FLAGS_quiet) { | 13 if (FLAGS_quiet) { |
15 return; | 14 return; |
16 } | 15 } |
17 | 16 |
| 17 // It's okay if these are a little off---they're just for show---so we can r
ead unprotectedly. |
| 18 const int32_t failed = SK_ANNOTATE_UNPROTECTED_READ(fFailed); |
| 19 const int32_t pending = SK_ANNOTATE_UNPROTECTED_READ(fPending) - 1; |
| 20 |
18 SkString status; | 21 SkString status; |
19 status.printf("%s%d tasks left", | 22 status.printf("%s%d tasks left", FLAGS_verbose ? "\n" : kSkOverwriteLine, pe
nding); |
20 FLAGS_verbose ? "\n" : kSkOverwriteLine, | |
21 this->started() - this->finished()); | |
22 const int failed = this->failed(); | |
23 if (failed > 0) { | 23 if (failed > 0) { |
24 status.appendf(", %d failed", failed); | 24 status.appendf(", %d failed", failed); |
25 } | 25 } |
26 if (FLAGS_verbose) { | 26 if (FLAGS_verbose) { |
27 status.appendf("\t%5dms %s", timeMs, name.c_str()); | 27 status.appendf("\t%5dms %s", timeMs, name.c_str()); |
28 } | 28 } |
29 SkDebugf("%s", status.c_str()); | 29 SkDebugf("%s", status.c_str()); |
30 } | 30 } |
31 | 31 |
32 int32_t Reporter::failed() const { | 32 void Reporter::fail(SkString msg) { |
33 SkAutoMutexAcquire reader(&fMutex); | 33 sk_atomic_inc(&fFailed); |
34 return fFailures.count(); | |
35 } | |
36 | 34 |
37 void Reporter::fail(SkString msg) { | |
38 SkAutoMutexAcquire writer(&fMutex); | 35 SkAutoMutexAcquire writer(&fMutex); |
39 fFailures.push_back(msg); | 36 fFailures.push_back(msg); |
40 } | 37 } |
41 | 38 |
42 void Reporter::getFailures(SkTArray<SkString>* failures) const { | 39 void Reporter::getFailures(SkTArray<SkString>* failures) const { |
43 SkAutoMutexAcquire reader(&fMutex); | 40 SkAutoMutexAcquire reader(&fMutex); |
44 *failures = fFailures; | 41 *failures = fFailures; |
45 } | 42 } |
46 | 43 |
47 } // namespace DM | 44 } // namespace DM |
OLD | NEW |