2013-10-16 13:02:15 +00:00
|
|
|
#include "DMReporter.h"
|
|
|
|
|
2014-05-29 20:14:48 +00:00
|
|
|
#include "SkDynamicAnnotations.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-05-29 20:14:48 +00:00
|
|
|
void Reporter::printStatus(SkString name, SkMSec timeMs) const {
|
2013-10-29 15:02:17 +00:00
|
|
|
if (FLAGS_quiet) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-05-29 20:14:48 +00:00
|
|
|
// It's okay if these are a little off---they're just for show---so we can read unprotectedly.
|
|
|
|
const int32_t failed = SK_ANNOTATE_UNPROTECTED_READ(fFailed);
|
|
|
|
const int32_t pending = SK_ANNOTATE_UNPROTECTED_READ(fPending) - 1;
|
|
|
|
|
2013-10-18 20:52:44 +00:00
|
|
|
SkString status;
|
2014-05-29 20:14:48 +00:00
|
|
|
status.printf("%s%d tasks left", FLAGS_verbose ? "\n" : kSkOverwriteLine, pending);
|
2013-10-18 20:52:44 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2014-02-26 16:31:22 +00:00
|
|
|
void Reporter::fail(SkString msg) {
|
2014-05-29 20:14:48 +00:00
|
|
|
sk_atomic_inc(&fFailed);
|
|
|
|
|
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
|