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

Side by Side Diff: dm/DM.cpp

Issue 1427033003: DM+VB: WallTimer -> SkTime::GetNSecs(). (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: tweak Created 5 years, 1 month 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 unified diff | Download patch
« no previous file with comments | « no previous file | tools/VisualBench/TimingStateMachine.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2013 Google Inc. 2 * Copyright 2013 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "CrashHandler.h" 8 #include "CrashHandler.h"
9 #include "DMJsonWriter.h" 9 #include "DMJsonWriter.h"
10 #include "DMSrcSink.h" 10 #include "DMSrcSink.h"
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 68
69 DEFINE_int32(shards, 1, "We're splitting source data into this many shards."); 69 DEFINE_int32(shards, 1, "We're splitting source data into this many shards.");
70 DEFINE_int32(shard, 0, "Which shard do I run?"); 70 DEFINE_int32(shard, 0, "Which shard do I run?");
71 DEFINE_bool2(pre_log, p, false, "Log before running each test. May be incomprehe nsible when threading"); 71 DEFINE_bool2(pre_log, p, false, "Log before running each test. May be incomprehe nsible when threading");
72 72
73 __SK_FORCE_IMAGE_DECODER_LINKING; 73 __SK_FORCE_IMAGE_DECODER_LINKING;
74 using namespace DM; 74 using namespace DM;
75 75
76 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~*/ 76 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~*/
77 77
78 static double now_ms() { return SkTime::GetNSecs() * 1e-6; }
79
78 SK_DECLARE_STATIC_MUTEX(gFailuresMutex); 80 SK_DECLARE_STATIC_MUTEX(gFailuresMutex);
79 static SkTArray<SkString> gFailures; 81 static SkTArray<SkString> gFailures;
80 82
81 static void fail(ImplicitString err) { 83 static void fail(ImplicitString err) {
82 SkAutoMutexAcquire lock(gFailuresMutex); 84 SkAutoMutexAcquire lock(gFailuresMutex);
83 SkDebugf("\n\nFAILURE: %s\n\n", err.c_str()); 85 SkDebugf("\n\nFAILURE: %s\n\n", err.c_str());
84 gFailures.push_back(err); 86 gFailures.push_back(err);
85 } 87 }
86 88
87 static int32_t gPending = 0; // Atomic. Total number of running and queued tas ks. 89 static int32_t gPending = 0; // Atomic. Total number of running and queued tas ks.
(...skipping 735 matching lines...) Expand 10 before | Expand all | Expand 10 after
823 // - this Src / Sink combination is on the blacklist; 825 // - this Src / Sink combination is on the blacklist;
824 // - it's a dry run. 826 // - it's a dry run.
825 SkString note(task->src->veto(task->sink->flags()) ? " (veto)" : ""); 827 SkString note(task->src->veto(task->sink->flags()) ? " (veto)" : "");
826 SkString whyBlacklisted = is_blacklisted(task->sink.tag, task->src.tag.c _str(), 828 SkString whyBlacklisted = is_blacklisted(task->sink.tag, task->src.tag.c _str(),
827 task->src.options.c_str(), name .c_str()); 829 task->src.options.c_str(), name .c_str());
828 if (!whyBlacklisted.isEmpty()) { 830 if (!whyBlacklisted.isEmpty()) {
829 note.appendf(" (--blacklist %s)", whyBlacklisted.c_str()); 831 note.appendf(" (--blacklist %s)", whyBlacklisted.c_str());
830 } 832 }
831 833
832 SkString log; 834 SkString log;
833 WallTimer timer; 835 auto timerStart = now_ms();
834 timer.start();
835 if (!FLAGS_dryRun && note.isEmpty()) { 836 if (!FLAGS_dryRun && note.isEmpty()) {
836 SkBitmap bitmap; 837 SkBitmap bitmap;
837 SkDynamicMemoryWStream stream; 838 SkDynamicMemoryWStream stream;
838 if (FLAGS_pre_log) { 839 if (FLAGS_pre_log) {
839 SkDebugf("\nRunning %s->%s", name.c_str(), task->sink.tag); 840 SkDebugf("\nRunning %s->%s", name.c_str(), task->sink.tag);
840 } 841 }
841 start(task->sink.tag, task->src.tag, task->src.options, name.c_str() ); 842 start(task->sink.tag, task->src.tag, task->src.options, name.c_str() );
842 Error err = task->sink->draw(*task->src, &bitmap, &stream, &log); 843 Error err = task->sink->draw(*task->src, &bitmap, &stream, &log);
843 if (!err.isEmpty()) { 844 if (!err.isEmpty()) {
844 timer.end(); 845 auto elapsed = now_ms() - timerStart;
845 if (err.isFatal()) { 846 if (err.isFatal()) {
846 fail(SkStringPrintf("%s %s %s %s: %s", 847 fail(SkStringPrintf("%s %s %s %s: %s",
847 task->sink.tag, 848 task->sink.tag,
848 task->src.tag.c_str(), 849 task->src.tag.c_str(),
849 task->src.options.c_str(), 850 task->src.options.c_str(),
850 name.c_str(), 851 name.c_str(),
851 err.c_str())); 852 err.c_str()));
852 } else { 853 } else {
853 note.appendf(" (skipped: %s)", err.c_str()); 854 note.appendf(" (skipped: %s)", err.c_str());
854 } 855 }
855 done(timer.fWall, task->sink.tag, task->src.tag, task->src.optio ns, 856 done(elapsed, task->sink.tag, task->src.tag, task->src.options,
856 name, note, log); 857 name, note, log);
857 return; 858 return;
858 } 859 }
859 SkAutoTDelete<SkStreamAsset> data(stream.detachAsStream()); 860 SkAutoTDelete<SkStreamAsset> data(stream.detachAsStream());
860 861
861 SkString md5; 862 SkString md5;
862 if (!FLAGS_writePath.isEmpty() || !FLAGS_readPath.isEmpty()) { 863 if (!FLAGS_writePath.isEmpty() || !FLAGS_readPath.isEmpty()) {
863 SkMD5 hash; 864 SkMD5 hash;
864 if (data->getLength()) { 865 if (data->getLength()) {
865 hash.writeStream(data, data->getLength()); 866 hash.writeStream(data, data->getLength());
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
899 if (!FLAGS_writePath.isEmpty()) { 900 if (!FLAGS_writePath.isEmpty()) {
900 const char* ext = task->sink->fileExtension(); 901 const char* ext = task->sink->fileExtension();
901 if (data->getLength()) { 902 if (data->getLength()) {
902 WriteToDisk(*task, md5, ext, data, data->getLength(), nullpt r); 903 WriteToDisk(*task, md5, ext, data, data->getLength(), nullpt r);
903 SkASSERT(bitmap.drawsNothing()); 904 SkASSERT(bitmap.drawsNothing());
904 } else if (!bitmap.drawsNothing()) { 905 } else if (!bitmap.drawsNothing()) {
905 WriteToDisk(*task, md5, ext, nullptr, 0, &bitmap); 906 WriteToDisk(*task, md5, ext, nullptr, 0, &bitmap);
906 } 907 }
907 } 908 }
908 } 909 }
909 timer.end(); 910 done(now_ms()-timerStart, task->sink.tag, task->src.tag.c_str(), task->s rc.options.c_str(),
910 done(timer.fWall, task->sink.tag, task->src.tag.c_str(), task->src.optio ns.c_str(), name, 911 name, note, log);
911 note, log);
912 } 912 }
913 913
914 static void WriteToDisk(const Task& task, 914 static void WriteToDisk(const Task& task,
915 SkString md5, 915 SkString md5,
916 const char* ext, 916 const char* ext,
917 SkStream* data, size_t len, 917 SkStream* data, size_t len,
918 const SkBitmap* bitmap) { 918 const SkBitmap* bitmap) {
919 JsonWriter::BitmapResult result; 919 JsonWriter::BitmapResult result;
920 result.name = task.src->name(); 920 result.name = task.src->name();
921 result.config = task.sink.tag; 921 result.config = task.sink.tag;
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
1025 } 1025 }
1026 bool verbose() const override { return FLAGS_veryVerbose; } 1026 bool verbose() const override { return FLAGS_veryVerbose; }
1027 } reporter; 1027 } reporter;
1028 1028
1029 SkString note; 1029 SkString note;
1030 SkString whyBlacklisted = is_blacklisted("_", "tests", "_", test->name); 1030 SkString whyBlacklisted = is_blacklisted("_", "tests", "_", test->name);
1031 if (!whyBlacklisted.isEmpty()) { 1031 if (!whyBlacklisted.isEmpty()) {
1032 note.appendf(" (--blacklist %s)", whyBlacklisted.c_str()); 1032 note.appendf(" (--blacklist %s)", whyBlacklisted.c_str());
1033 } 1033 }
1034 1034
1035 WallTimer timer; 1035 auto timerStart = now_ms();
1036 timer.start();
1037 if (!FLAGS_dryRun && whyBlacklisted.isEmpty()) { 1036 if (!FLAGS_dryRun && whyBlacklisted.isEmpty()) {
1038 start("unit", "test", "", test->name); 1037 start("unit", "test", "", test->name);
1039 GrContextFactory factory; 1038 GrContextFactory factory;
1040 if (FLAGS_pre_log) { 1039 if (FLAGS_pre_log) {
1041 SkDebugf("\nRunning test %s", test->name); 1040 SkDebugf("\nRunning test %s", test->name);
1042 } 1041 }
1043 test->proc(&reporter, &factory); 1042 test->proc(&reporter, &factory);
1044 } 1043 }
1045 timer.end(); 1044 done(now_ms()-timerStart, "unit", "test", "", test->name, note, "");
1046 done(timer.fWall, "unit", "test", "", test->name, note, "");
1047 } 1045 }
1048 1046
1049 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~*/ 1047 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~*/
1050 1048
1051 // If we're isolating all GPU-bound work to one thread (the default), this funct ion runs all that. 1049 // If we're isolating all GPU-bound work to one thread (the default), this funct ion runs all that.
1052 static void run_enclave_and_gpu_tests(SkTArray<Task>* tasks) { 1050 static void run_enclave_and_gpu_tests(SkTArray<Task>* tasks) {
1053 run_enclave(tasks); 1051 run_enclave(tasks);
1054 for (int i = 0; i < gGPUTests.count(); i++) { 1052 for (int i = 0; i < gGPUTests.count(); i++) {
1055 run_test(&gGPUTests[i]); 1053 run_test(&gGPUTests[i]);
1056 } 1054 }
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
1165 #endif // SK_PDF_IMAGE_STATS 1163 #endif // SK_PDF_IMAGE_STATS
1166 return 0; 1164 return 0;
1167 } 1165 }
1168 1166
1169 #if !defined(SK_BUILD_FOR_IOS) 1167 #if !defined(SK_BUILD_FOR_IOS)
1170 int main(int argc, char** argv) { 1168 int main(int argc, char** argv) {
1171 SkCommandLineFlags::Parse(argc, argv); 1169 SkCommandLineFlags::Parse(argc, argv);
1172 return dm_main(); 1170 return dm_main();
1173 } 1171 }
1174 #endif 1172 #endif
OLDNEW
« no previous file with comments | « no previous file | tools/VisualBench/TimingStateMachine.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698