blob: 7b2cea8136f32f82d1385f4ee3b2d16574c983ef [file] [log] [blame]
mtklein@google.comd36522d2013-10-16 13:02:15 +00001#include "DMReporter.h"
2
commit-bot@chromium.org39e8d932014-05-29 20:14:48 +00003#include "SkDynamicAnnotations.h"
caryclark17f0b6d2014-07-22 10:15:34 -07004#include "SkCommonFlags.h"
commit-bot@chromium.org261c6662014-01-02 16:19:53 +00005#include "OverwriteLine.h"
halcanary0d154ee2014-08-11 11:33:51 -07006#include "ProcStats.h"
mtklein4e212e82014-08-04 14:10:19 -07007
mtklein@google.comd36522d2013-10-16 13:02:15 +00008namespace DM {
9
commit-bot@chromium.org39e8d932014-05-29 20:14:48 +000010void Reporter::printStatus(SkString name, SkMSec timeMs) const {
commit-bot@chromium.org0caa68a2013-10-29 15:02:17 +000011 if (FLAGS_quiet) {
12 return;
13 }
14
commit-bot@chromium.org39e8d932014-05-29 20:14:48 +000015 // 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.coma7a9f372013-10-18 20:52:44 +000019 SkString status;
commit-bot@chromium.org39e8d932014-05-29 20:14:48 +000020 status.printf("%s%d tasks left", FLAGS_verbose ? "\n" : kSkOverwriteLine, pending);
mtklein@google.coma7a9f372013-10-18 20:52:44 +000021 if (failed > 0) {
22 status.appendf(", %d failed", failed);
23 }
commit-bot@chromium.orga39874b2014-03-03 15:44:56 +000024 if (FLAGS_verbose) {
mtkleinafb43792014-08-19 15:55:55 -070025 int max_rss_mb = sk_tools::getMaxResidentSetSizeMB();
26 if (max_rss_mb >= 0) {
27 status.appendf("\t%4dM peak", max_rss_mb);
mtklein4e212e82014-08-04 14:10:19 -070028 }
29 status.appendf("\t%5dms\t%s", timeMs, name.c_str());
commit-bot@chromium.orga39874b2014-03-03 15:44:56 +000030 }
commit-bot@chromium.orgd1a7e2e2014-02-28 20:28:59 +000031 SkDebugf("%s", status.c_str());
mtklein@google.comd36522d2013-10-16 13:02:15 +000032}
33
commit-bot@chromium.org0dc5bd12014-02-26 16:31:22 +000034void Reporter::fail(SkString msg) {
commit-bot@chromium.org39e8d932014-05-29 20:14:48 +000035 sk_atomic_inc(&fFailed);
36
mtklein@google.comd36522d2013-10-16 13:02:15 +000037 SkAutoMutexAcquire writer(&fMutex);
commit-bot@chromium.org0dc5bd12014-02-26 16:31:22 +000038 fFailures.push_back(msg);
mtklein@google.comd36522d2013-10-16 13:02:15 +000039}
40
41void Reporter::getFailures(SkTArray<SkString>* failures) const {
42 SkAutoMutexAcquire reader(&fMutex);
43 *failures = fFailures;
44}
45
46} // namespace DM