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