Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1684)

Unified Diff: dm/DM.cpp

Issue 1727363004: trim DM fat (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dm/DM.cpp
diff --git a/dm/DM.cpp b/dm/DM.cpp
index 5c27c450ba52c9a3bda1537bc7ece6d747409e66..f37fc8b7fff8eeab49ac62ce5f0a098580aacb03 100644
--- a/dm/DM.cpp
+++ b/dm/DM.cpp
@@ -71,12 +71,10 @@ using namespace DM;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-static double now_ms() { return SkTime::GetNSecs() * 1e-6; }
-
SK_DECLARE_STATIC_MUTEX(gFailuresMutex);
static SkTArray<SkString> gFailures;
-static void fail(ImplicitString err) {
+static void fail(const SkString& err) {
SkAutoMutexAcquire lock(gFailuresMutex);
SkDebugf("\n\nFAILURE: %s\n\n", err.c_str());
gFailures.push_back(err);
@@ -85,15 +83,11 @@ static void fail(ImplicitString err) {
// We use a spinlock to make locking this in a signal handler _somewhat_ safe.
SK_DECLARE_STATIC_SPINLOCK(gMutex);
-static int32_t gPending;
-static SkTArray<SkString> gRunning;
-static SkTHashMap<SkString, int> gNoteTally;
-
-static void done(double ms,
- ImplicitString config, ImplicitString src, ImplicitString srcOptions,
- ImplicitString name, ImplicitString note, ImplicitString log) {
- SkString id = SkStringPrintf("%s %s %s %s", config.c_str(), src.c_str(),
- srcOptions.c_str(), name.c_str());
+static int32_t gPending;
+static SkTArray<SkString> gRunning;
+
+static void done(const char* config, const char* src, const char* srcOptions, const char* name) {
+ SkString id = SkStringPrintf("%s %s %s %s", config, src, srcOptions, name);
int pending;
{
SkAutoTAcquire<SkPODSpinlock> lock(gMutex);
@@ -103,13 +97,6 @@ static void done(double ms,
break;
}
}
- if (!note.isEmpty()) {
- if (int* tally = gNoteTally.find(note)) {
- *tally += 1;
- } else {
- gNoteTally.set(note, 1);
- }
- }
pending = --gPending;
}
// We write our dm.json file every once in a while in case we crash.
@@ -119,10 +106,8 @@ static void done(double ms,
}
}
-static void start(ImplicitString config, ImplicitString src,
- ImplicitString srcOptions, ImplicitString name) {
- SkString id = SkStringPrintf("%s %s %s %s", config.c_str(), src.c_str(),
- srcOptions.c_str(), name.c_str());
+static void start(const char* config, const char* src, const char* srcOptions, const char* name) {
+ SkString id = SkStringPrintf("%s %s %s %s", config, src, srcOptions, name);
SkAutoTAcquire<SkPODSpinlock> lock(gMutex);
gRunning.push_back(id);
}
@@ -165,8 +150,9 @@ static void print_status() {
struct Gold : public SkString {
Gold() : SkString("") {}
- Gold(ImplicitString sink, ImplicitString src, ImplicitString srcOptions,
- ImplicitString name, ImplicitString md5)
+ Gold(const SkString& sink, const SkString& src,
+ const SkString& srcOptions, const SkString& name,
+ const SkString& md5)
: SkString("") {
this->append(sink);
this->append(src);
@@ -221,8 +207,8 @@ static void gather_uninteresting_hashes() {
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
struct TaggedSrc : public SkAutoTDelete<Src> {
- ImplicitString tag;
- ImplicitString options;
+ SkString tag;
+ SkString options;
};
struct TaggedSink : public SkAutoTDelete<Sink> {
@@ -239,10 +225,10 @@ static bool in_shard() {
return N++ % FLAGS_shards == FLAGS_shard;
}
-static void push_src(ImplicitString tag, ImplicitString options, Src* s) {
+static void push_src(const char* tag, ImplicitString options, Src* s) {
SkAutoTDelete<Src> src(s);
if (in_shard() &&
- FLAGS_src.contains(tag.c_str()) &&
+ FLAGS_src.contains(tag) &&
!SkCommandLineFlags::ShouldSkip(FLAGS_match, src->name().c_str())) {
TaggedSrc& s = gSrcs.push_back();
s.reset(src.detach());
@@ -856,19 +842,17 @@ static bool match(const char* needle, const char* haystack) {
return 0 == strcmp("_", needle) || nullptr != strstr(haystack, needle);
}
-static ImplicitString is_blacklisted(const char* sink, const char* src,
- const char* srcOptions, const char* name) {
+static bool is_blacklisted(const char* sink, const char* src,
+ const char* srcOptions, const char* name) {
for (int i = 0; i < FLAGS_blacklist.count() - 3; i += 4) {
if (match(FLAGS_blacklist[i+0], sink) &&
match(FLAGS_blacklist[i+1], src) &&
match(FLAGS_blacklist[i+2], srcOptions) &&
match(FLAGS_blacklist[i+3], name)) {
- return SkStringPrintf("%s %s %s %s",
- FLAGS_blacklist[i+0], FLAGS_blacklist[i+1],
- FLAGS_blacklist[i+2], FLAGS_blacklist[i+3]);
+ return true;
}
}
- return "";
+ return false;
}
// Even when a Task Sink reports to be non-threadsafe (e.g. GPU), we know things like
@@ -885,23 +869,12 @@ struct Task {
static void Run(const Task& task) {
SkString name = task.src->name();
- // We'll skip drawing this Src/Sink pair if:
- // - the Src vetoes the Sink;
- // - this Src / Sink combination is on the blacklist;
- // - it's a dry run.
- SkString note(task.src->veto(task.sink->flags()) ? " (veto)" : "");
- SkString whyBlacklisted = is_blacklisted(task.sink.tag.c_str(), task.src.tag.c_str(),
- task.src.options.c_str(), name.c_str());
- if (!whyBlacklisted.isEmpty()) {
- note.appendf(" (--blacklist %s)", whyBlacklisted.c_str());
- }
-
SkString log;
- auto timerStart = now_ms();
- if (!FLAGS_dryRun && note.isEmpty()) {
+ if (!FLAGS_dryRun) {
SkBitmap bitmap;
SkDynamicMemoryWStream stream;
- start(task.sink.tag.c_str(), task.src.tag, task.src.options, name.c_str());
+ start(task.sink.tag.c_str(), task.src.tag.c_str(),
+ task.src.options.c_str(), name.c_str());
Error err = task.sink->draw(*task.src, &bitmap, &stream, &log);
if (!err.isEmpty()) {
if (err.isFatal()) {
@@ -912,10 +885,8 @@ struct Task {
name.c_str(),
err.c_str()));
} else {
- note.appendf(" (skipped: %s)", err.c_str());
- auto elapsed = now_ms() - timerStart;
- done(elapsed, task.sink.tag.c_str(), task.src.tag, task.src.options,
- name, note, log);
+ done(task.sink.tag.c_str(), task.src.tag.c_str(),
+ task.src.options.c_str(), name.c_str());
return;
}
}
@@ -955,8 +926,8 @@ struct Task {
}
if (!FLAGS_readPath.isEmpty() &&
- !gGold.contains(Gold(task.sink.tag.c_str(), task.src.tag.c_str(),
- task.src.options.c_str(), name, md5))) {
+ !gGold.contains(Gold(task.sink.tag, task.src.tag,
+ task.src.options, name, md5))) {
fail(SkStringPrintf("%s not found for %s %s %s %s in %s",
md5.c_str(),
task.sink.tag.c_str(),
@@ -977,9 +948,7 @@ struct Task {
}
});
}
- auto elapsed = now_ms() - timerStart;
- done(elapsed, task.sink.tag.c_str(), task.src.tag.c_str(), task.src.options.c_str(),
- name, note, log);
+ done(task.sink.tag.c_str(), task.src.tag.c_str(), task.src.options.c_str(), name.c_str());
}
static void WriteToDisk(const Task& task,
@@ -989,7 +958,7 @@ struct Task {
const SkBitmap* bitmap) {
JsonWriter::BitmapResult result;
result.name = task.src->name();
- result.config = task.sink.tag.c_str();
+ result.config = task.sink.tag;
result.sourceType = task.src.tag;
result.sourceOptions = task.src.options;
result.ext = ext;
@@ -1089,19 +1058,12 @@ static void run_test(skiatest::Test test) {
bool verbose() const override { return FLAGS_veryVerbose; }
} reporter;
- SkString note;
- SkString whyBlacklisted = is_blacklisted("_", "tests", "_", test.name);
- if (!whyBlacklisted.isEmpty()) {
- note.appendf(" (--blacklist %s)", whyBlacklisted.c_str());
- }
-
- auto timerStart = now_ms();
- if (!FLAGS_dryRun && whyBlacklisted.isEmpty()) {
+ if (!FLAGS_dryRun && !is_blacklisted("_", "tests", "_", test.name)) {
start("unit", "test", "", test.name);
GrContextFactory factory;
test.proc(&reporter, &factory);
}
- done(now_ms()-timerStart, "unit", "test", "", test.name, note, "");
+ done("unit", "test", "", test.name);
}
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
@@ -1173,6 +1135,14 @@ int dm_main() {
for (auto& sink : gSinks)
for (auto& src : gSrcs) {
+ if (src->veto(sink->flags()) ||
+ is_blacklisted(sink.tag.c_str(), src.tag.c_str(),
+ src.options.c_str(), src->name().c_str())) {
+ SkAutoTAcquire<SkPODSpinlock> lock(gMutex);
+ gPending--;
+ continue;
+ }
+
Task task(src, sink);
if (src->serial() || sink->serial()) {
serial.push_back(task);
@@ -1198,14 +1168,6 @@ int dm_main() {
// At this point we're back in single-threaded land.
sk_tool_utils::release_portable_typefaces();
- if (FLAGS_verbose && gNoteTally.count() > 0) {
- SkDebugf("\nNote tally:\n");
- gNoteTally.foreach([](const SkString& note, int* tally) {
- SkDebugf("%dx\t%s\n", *tally, note.c_str());
- });
- }
-
- SkDebugf("\n");
if (gFailures.count() > 0) {
SkDebugf("Failures:\n");
for (int i = 0; i < gFailures.count(); i++) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698