OLD | NEW |
1 #include "DMReporter.h" | 1 #include "DMReporter.h" |
2 | 2 |
3 #include "SkDynamicAnnotations.h" | 3 #include "SkDynamicAnnotations.h" |
4 #include "SkCommonFlags.h" | 4 #include "SkCommonFlags.h" |
5 #include "OverwriteLine.h" | 5 #include "OverwriteLine.h" |
6 | 6 |
| 7 #ifdef SK_BUILD_FOR_UNIX |
| 8 #include <sys/resource.h> |
| 9 static long get_max_rss_kb() { |
| 10 struct rusage ru; |
| 11 getrusage(RUSAGE_SELF, &ru); |
| 12 return ru.ru_maxrss; |
| 13 } |
| 14 #else |
| 15 static long get_max_rss_kb() { return 0; } |
| 16 #endif |
| 17 |
7 namespace DM { | 18 namespace DM { |
8 | 19 |
9 void Reporter::printStatus(SkString name, SkMSec timeMs) const { | 20 void Reporter::printStatus(SkString name, SkMSec timeMs) const { |
10 if (FLAGS_quiet) { | 21 if (FLAGS_quiet) { |
11 return; | 22 return; |
12 } | 23 } |
13 | 24 |
14 // It's okay if these are a little off---they're just for show---so we can r
ead unprotectedly. | 25 // It's okay if these are a little off---they're just for show---so we can r
ead unprotectedly. |
15 const int32_t failed = SK_ANNOTATE_UNPROTECTED_READ(fFailed); | 26 const int32_t failed = SK_ANNOTATE_UNPROTECTED_READ(fFailed); |
16 const int32_t pending = SK_ANNOTATE_UNPROTECTED_READ(fPending) - 1; | 27 const int32_t pending = SK_ANNOTATE_UNPROTECTED_READ(fPending) - 1; |
17 | 28 |
18 SkString status; | 29 SkString status; |
19 status.printf("%s%d tasks left", FLAGS_verbose ? "\n" : kSkOverwriteLine, pe
nding); | 30 status.printf("%s%d tasks left", FLAGS_verbose ? "\n" : kSkOverwriteLine, pe
nding); |
20 if (failed > 0) { | 31 if (failed > 0) { |
21 status.appendf(", %d failed", failed); | 32 status.appendf(", %d failed", failed); |
22 } | 33 } |
23 if (FLAGS_verbose) { | 34 if (FLAGS_verbose) { |
24 status.appendf("\t%5dms %s", timeMs, name.c_str()); | 35 if (long max_rss_kb = get_max_rss_kb()) { |
| 36 status.appendf("\t%4ldM peak", max_rss_kb / 1024); |
| 37 } |
| 38 status.appendf("\t%5dms\t%s", timeMs, name.c_str()); |
25 } | 39 } |
26 SkDebugf("%s", status.c_str()); | 40 SkDebugf("%s", status.c_str()); |
27 } | 41 } |
28 | 42 |
29 void Reporter::fail(SkString msg) { | 43 void Reporter::fail(SkString msg) { |
30 sk_atomic_inc(&fFailed); | 44 sk_atomic_inc(&fFailed); |
31 | 45 |
32 SkAutoMutexAcquire writer(&fMutex); | 46 SkAutoMutexAcquire writer(&fMutex); |
33 fFailures.push_back(msg); | 47 fFailures.push_back(msg); |
34 } | 48 } |
35 | 49 |
36 void Reporter::getFailures(SkTArray<SkString>* failures) const { | 50 void Reporter::getFailures(SkTArray<SkString>* failures) const { |
37 SkAutoMutexAcquire reader(&fMutex); | 51 SkAutoMutexAcquire reader(&fMutex); |
38 *failures = fFailures; | 52 *failures = fFailures; |
39 } | 53 } |
40 | 54 |
41 } // namespace DM | 55 } // namespace DM |
OLD | NEW |