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

Unified Diff: components/dom_distiller/core/distiller_unittest.cc

Issue 717643003: Extract timing info from distiller result (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@dd-roll-perf
Patch Set: Created 6 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 side-by-side diff with in-line comments
Download patch
Index: components/dom_distiller/core/distiller_unittest.cc
diff --git a/components/dom_distiller/core/distiller_unittest.cc b/components/dom_distiller/core/distiller_unittest.cc
index d55e4f74b86ecdbc61cf0404c8a85fa7312754fc..52fa93a628f0045e98487df342c2e97190826673 100644
--- a/components/dom_distiller/core/distiller_unittest.cc
+++ b/components/dom_distiller/core/distiller_unittest.cc
@@ -34,6 +34,7 @@ using ::testing::_;
using dom_distiller::proto::DomDistillerOptions;
using dom_distiller::proto::DomDistillerResult;
+using dom_distiller::proto::TimingEntry;
namespace {
const char kTitle[] = "Title";
@@ -360,6 +361,45 @@ TEST_F(DistillerTest, DistillPageWithDebugInfo) {
EXPECT_EQ(kDebugLog, first_page.debug_info().log());
}
+void SetTimingEntry(TimingEntry* entry, const std::string& name, double time) {
+ entry->set_name(name);
+ entry->set_time(time);
+}
+
+TEST_F(DistillerTest, DistillPageWithTimingInfo) {
+ base::MessageLoopForUI loop;
+ DomDistillerResult dd_result;
+ dd_result.mutable_timing_info()->set_total_time(1.0);
+ dd_result.mutable_timing_info()->set_markup_parsing_time(2.0);
+ dd_result.mutable_timing_info()->set_document_construction_time(3.0);
+ dd_result.mutable_timing_info()->set_article_processing_time(4.0);
+ dd_result.mutable_timing_info()->set_formatting_time(5.0);
+ SetTimingEntry(
+ dd_result.mutable_timing_info()->add_other_times(), "time0", 6.0);
+ SetTimingEntry(
+ dd_result.mutable_timing_info()->add_other_times(), "time1", 7.0);
+ scoped_ptr<base::Value> result =
+ dom_distiller::proto::json::DomDistillerResult::WriteToValue(dd_result);
+ distiller_.reset(
+ new DistillerImpl(url_fetcher_factory_, DomDistillerOptions()));
+ DistillPage(kURL, CreateMockDistillerPage(result.get(), GURL(kURL)).Pass());
+ base::MessageLoop::current()->RunUntilIdle();
+ const DistilledPageProto& first_page = article_proto_->pages(0);
+ std::map<std::string, double> timings;
+ for (int i = 0; i < first_page.timing_info_size(); ++i) {
+ DistilledPageProto::TimingInfo timing = first_page.timing_info(i);
+ timings[timing.name()] = timing.time();
+ }
+ EXPECT_EQ(7u, timings.size());
+ EXPECT_EQ(1.0, timings["total"]);
+ EXPECT_EQ(2.0, timings["markup_parsing"]);
+ EXPECT_EQ(3.0, timings["document_construction"]);
+ EXPECT_EQ(4.0, timings["article_processing"]);
+ EXPECT_EQ(5.0, timings["formatting"]);
+ EXPECT_EQ(6.0, timings["time0"]);
+ EXPECT_EQ(7.0, timings["time1"]);
+}
+
TEST_F(DistillerTest, DistillPageWithImages) {
base::MessageLoopForUI loop;
vector<int> image_indices;
« no previous file with comments | « components/dom_distiller/core/distiller.cc ('k') | components/dom_distiller/core/proto/distilled_page.proto » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698