mtklein@google.com | d36522d | 2013-10-16 13:02:15 +0000 | [diff] [blame] | 1 | #include "DMReporter.h" |
| 2 | |
commit-bot@chromium.org | 0caa68a | 2013-10-29 15:02:17 +0000 | [diff] [blame] | 3 | #include "SkCommandLineFlags.h" |
commit-bot@chromium.org | 261c666 | 2014-01-02 16:19:53 +0000 | [diff] [blame] | 4 | #include "OverwriteLine.h" |
commit-bot@chromium.org | 0caa68a | 2013-10-29 15:02:17 +0000 | [diff] [blame] | 5 | |
commit-bot@chromium.org | 0dc5bd1 | 2014-02-26 16:31:22 +0000 | [diff] [blame] | 6 | 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."); |
commit-bot@chromium.org | 0caa68a | 2013-10-29 15:02:17 +0000 | [diff] [blame] | 8 | |
mtklein@google.com | d36522d | 2013-10-16 13:02:15 +0000 | [diff] [blame] | 9 | namespace DM { |
| 10 | |
commit-bot@chromium.org | a39874b | 2014-03-03 15:44:56 +0000 | [diff] [blame] | 11 | void Reporter::finish(SkString name, SkMSec timeMs) { |
commit-bot@chromium.org | 0dc5bd1 | 2014-02-26 16:31:22 +0000 | [diff] [blame] | 12 | sk_atomic_inc(&fFinished); |
| 13 | |
commit-bot@chromium.org | 0caa68a | 2013-10-29 15:02:17 +0000 | [diff] [blame] | 14 | if (FLAGS_quiet) { |
| 15 | return; |
| 16 | } |
| 17 | |
mtklein@google.com | a7a9f37 | 2013-10-18 20:52:44 +0000 | [diff] [blame] | 18 | SkString status; |
commit-bot@chromium.org | 0dc5bd1 | 2014-02-26 16:31:22 +0000 | [diff] [blame] | 19 | status.printf("%s%d tasks left", |
| 20 | FLAGS_verbose ? "\n" : kSkOverwriteLine, |
| 21 | this->started() - this->finished()); |
mtklein@google.com | a7a9f37 | 2013-10-18 20:52:44 +0000 | [diff] [blame] | 22 | const int failed = this->failed(); |
| 23 | if (failed > 0) { |
| 24 | status.appendf(", %d failed", failed); |
| 25 | } |
commit-bot@chromium.org | a39874b | 2014-03-03 15:44:56 +0000 | [diff] [blame] | 26 | if (FLAGS_verbose) { |
| 27 | status.appendf("\t%5dms %s", timeMs, name.c_str()); |
| 28 | } |
commit-bot@chromium.org | d1a7e2e | 2014-02-28 20:28:59 +0000 | [diff] [blame] | 29 | SkDebugf("%s", status.c_str()); |
mtklein@google.com | d36522d | 2013-10-16 13:02:15 +0000 | [diff] [blame] | 30 | } |
| 31 | |
| 32 | int32_t Reporter::failed() const { |
| 33 | SkAutoMutexAcquire reader(&fMutex); |
| 34 | return fFailures.count(); |
| 35 | } |
| 36 | |
commit-bot@chromium.org | 0dc5bd1 | 2014-02-26 16:31:22 +0000 | [diff] [blame] | 37 | void Reporter::fail(SkString msg) { |
mtklein@google.com | d36522d | 2013-10-16 13:02:15 +0000 | [diff] [blame] | 38 | SkAutoMutexAcquire writer(&fMutex); |
commit-bot@chromium.org | 0dc5bd1 | 2014-02-26 16:31:22 +0000 | [diff] [blame] | 39 | fFailures.push_back(msg); |
mtklein@google.com | d36522d | 2013-10-16 13:02:15 +0000 | [diff] [blame] | 40 | } |
| 41 | |
| 42 | void Reporter::getFailures(SkTArray<SkString>* failures) const { |
| 43 | SkAutoMutexAcquire reader(&fMutex); |
| 44 | *failures = fFailures; |
| 45 | } |
| 46 | |
| 47 | } // namespace DM |