2013-10-16 13:02:15 +00:00
|
|
|
#include "DMReporter.h"
|
|
|
|
|
2013-10-29 15:02:17 +00:00
|
|
|
#include "SkCommandLineFlags.h"
|
2014-01-02 16:19:53 +00:00
|
|
|
#include "OverwriteLine.h"
|
2013-10-29 15:02:17 +00:00
|
|
|
|
2014-02-26 16:31:22 +00:00
|
|
|
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.");
|
2013-10-29 15:02:17 +00:00
|
|
|
|
2013-10-16 13:02:15 +00:00
|
|
|
namespace DM {
|
|
|
|
|
2014-03-03 15:44:56 +00:00
|
|
|
void Reporter::finish(SkString name, SkMSec timeMs) {
|
2014-02-26 16:31:22 +00:00
|
|
|
sk_atomic_inc(&fFinished);
|
|
|
|
|
2013-10-29 15:02:17 +00:00
|
|
|
if (FLAGS_quiet) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-10-18 20:52:44 +00:00
|
|
|
SkString status;
|
2014-02-26 16:31:22 +00:00
|
|
|
status.printf("%s%d tasks left",
|
|
|
|
FLAGS_verbose ? "\n" : kSkOverwriteLine,
|
|
|
|
this->started() - this->finished());
|
2013-10-18 20:52:44 +00:00
|
|
|
const int failed = this->failed();
|
|
|
|
if (failed > 0) {
|
|
|
|
status.appendf(", %d failed", failed);
|
|
|
|
}
|
2014-03-03 15:44:56 +00:00
|
|
|
if (FLAGS_verbose) {
|
|
|
|
status.appendf("\t%5dms %s", timeMs, name.c_str());
|
|
|
|
}
|
2014-02-28 20:28:59 +00:00
|
|
|
SkDebugf("%s", status.c_str());
|
2013-10-16 13:02:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int32_t Reporter::failed() const {
|
|
|
|
SkAutoMutexAcquire reader(&fMutex);
|
|
|
|
return fFailures.count();
|
|
|
|
}
|
|
|
|
|
2014-02-26 16:31:22 +00:00
|
|
|
void Reporter::fail(SkString msg) {
|
2013-10-16 13:02:15 +00:00
|
|
|
SkAutoMutexAcquire writer(&fMutex);
|
2014-02-26 16:31:22 +00:00
|
|
|
fFailures.push_back(msg);
|
2013-10-16 13:02:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Reporter::getFailures(SkTArray<SkString>* failures) const {
|
|
|
|
SkAutoMutexAcquire reader(&fMutex);
|
|
|
|
*failures = fFailures;
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace DM
|