mtklein@google.com | d36522d | 2013-10-16 13:02:15 +0000 | [diff] [blame] | 1 | #include "DMReporter.h" |
| 2 | |
commit-bot@chromium.org | 39e8d93 | 2014-05-29 20:14:48 +0000 | [diff] [blame] | 3 | #include "SkDynamicAnnotations.h" |
caryclark | 17f0b6d | 2014-07-22 10:15:34 -0700 | [diff] [blame] | 4 | #include "SkCommonFlags.h" |
commit-bot@chromium.org | 261c666 | 2014-01-02 16:19:53 +0000 | [diff] [blame] | 5 | #include "OverwriteLine.h" |
halcanary | 0d154ee | 2014-08-11 11:33:51 -0700 | [diff] [blame] | 6 | #include "ProcStats.h" |
mtklein | 4e212e8 | 2014-08-04 14:10:19 -0700 | [diff] [blame] | 7 | |
mtklein@google.com | d36522d | 2013-10-16 13:02:15 +0000 | [diff] [blame] | 8 | namespace DM { |
| 9 | |
commit-bot@chromium.org | 39e8d93 | 2014-05-29 20:14:48 +0000 | [diff] [blame] | 10 | void Reporter::printStatus(SkString name, SkMSec timeMs) const { |
commit-bot@chromium.org | 0caa68a | 2013-10-29 15:02:17 +0000 | [diff] [blame] | 11 | if (FLAGS_quiet) { |
| 12 | return; |
| 13 | } |
| 14 | |
commit-bot@chromium.org | 39e8d93 | 2014-05-29 20:14:48 +0000 | [diff] [blame] | 15 | // It's okay if these are a little off---they're just for show---so we can read unprotectedly. |
| 16 | const int32_t failed = SK_ANNOTATE_UNPROTECTED_READ(fFailed); |
| 17 | const int32_t pending = SK_ANNOTATE_UNPROTECTED_READ(fPending) - 1; |
| 18 | |
mtklein@google.com | a7a9f37 | 2013-10-18 20:52:44 +0000 | [diff] [blame] | 19 | SkString status; |
commit-bot@chromium.org | 39e8d93 | 2014-05-29 20:14:48 +0000 | [diff] [blame] | 20 | status.printf("%s%d tasks left", FLAGS_verbose ? "\n" : kSkOverwriteLine, pending); |
mtklein@google.com | a7a9f37 | 2013-10-18 20:52:44 +0000 | [diff] [blame] | 21 | if (failed > 0) { |
| 22 | status.appendf(", %d failed", failed); |
| 23 | } |
commit-bot@chromium.org | a39874b | 2014-03-03 15:44:56 +0000 | [diff] [blame] | 24 | if (FLAGS_verbose) { |
mtklein | afb4379 | 2014-08-19 15:55:55 -0700 | [diff] [blame] | 25 | int max_rss_mb = sk_tools::getMaxResidentSetSizeMB(); |
| 26 | if (max_rss_mb >= 0) { |
| 27 | status.appendf("\t%4dM peak", max_rss_mb); |
mtklein | 4e212e8 | 2014-08-04 14:10:19 -0700 | [diff] [blame] | 28 | } |
| 29 | status.appendf("\t%5dms\t%s", timeMs, name.c_str()); |
commit-bot@chromium.org | a39874b | 2014-03-03 15:44:56 +0000 | [diff] [blame] | 30 | } |
commit-bot@chromium.org | d1a7e2e | 2014-02-28 20:28:59 +0000 | [diff] [blame] | 31 | SkDebugf("%s", status.c_str()); |
mtklein@google.com | d36522d | 2013-10-16 13:02:15 +0000 | [diff] [blame] | 32 | } |
| 33 | |
commit-bot@chromium.org | 0dc5bd1 | 2014-02-26 16:31:22 +0000 | [diff] [blame] | 34 | void Reporter::fail(SkString msg) { |
commit-bot@chromium.org | 39e8d93 | 2014-05-29 20:14:48 +0000 | [diff] [blame] | 35 | sk_atomic_inc(&fFailed); |
| 36 | |
mtklein@google.com | d36522d | 2013-10-16 13:02:15 +0000 | [diff] [blame] | 37 | SkAutoMutexAcquire writer(&fMutex); |
commit-bot@chromium.org | 0dc5bd1 | 2014-02-26 16:31:22 +0000 | [diff] [blame] | 38 | fFailures.push_back(msg); |
mtklein@google.com | d36522d | 2013-10-16 13:02:15 +0000 | [diff] [blame] | 39 | } |
| 40 | |
| 41 | void Reporter::getFailures(SkTArray<SkString>* failures) const { |
| 42 | SkAutoMutexAcquire reader(&fMutex); |
| 43 | *failures = fFailures; |
| 44 | } |
| 45 | |
| 46 | } // namespace DM |