aboutsummaryrefslogtreecommitdiffhomepage
path: root/dm/DMReporter.cpp
blob: 4bb25d349dffe193b853c1b3481ef9177db824ac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include "DMReporter.h"

#include "SkCommandLineFlags.h"
#include "OverwriteLine.h"

DEFINE_bool2(quiet, q, false, "If true, don't print status updates.");
DEFINE_bool2(verbose, v, false, "If true, print status updates one-per-line.");

namespace DM {

void Reporter::finish(SkString name, SkMSec timeMs) {
    sk_atomic_inc(&fFinished);

    if (FLAGS_quiet) {
        return;
    }

    SkString status;
    status.printf("%s%d tasks left",
                  FLAGS_verbose ? "\n" : kSkOverwriteLine,
                  this->started() - this->finished());
    const int failed = this->failed();
    if (failed > 0) {
        status.appendf(", %d failed", failed);
    }
    if (FLAGS_verbose) {
        status.appendf("\t%5dms %s", timeMs, name.c_str());
    }
    SkDebugf("%s", status.c_str());
}

int32_t Reporter::failed() const {
    SkAutoMutexAcquire reader(&fMutex);
    return fFailures.count();
}

void Reporter::fail(SkString msg) {
    SkAutoMutexAcquire writer(&fMutex);
    fFailures.push_back(msg);
}

void Reporter::getFailures(SkTArray<SkString>* failures) const {
    SkAutoMutexAcquire reader(&fMutex);
    *failures = fFailures;
}

}  // namespace DM