diff options
author | vandebo@chromium.org <vandebo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-30 02:26:27 +0000 |
---|---|---|
committer | vandebo@chromium.org <vandebo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-30 02:26:27 +0000 |
commit | 628bc54cf1a4006c7b65c8d9a7a3ce1d0ce5b047 (patch) | |
tree | dffb2d74e0f8fa61768ee4426f1bc3c7d323bbbe /chrome/renderer | |
parent | cd6522da39348968884d53d2db709f48d8b7716b (diff) | |
download | chromium_src-628bc54cf1a4006c7b65c8d9a7a3ce1d0ce5b047.zip chromium_src-628bc54cf1a4006c7b65c8d9a7a3ce1d0ce5b047.tar.gz chromium_src-628bc54cf1a4006c7b65c8d9a7a3ce1d0ce5b047.tar.bz2 |
Improve print preview UMAs based on jar's feedback.
BUG=80917
TEST=NONE
Review URL: http://codereview.chromium.org/7082030
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@87211 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer')
-rw-r--r-- | chrome/renderer/print_web_view_helper.cc | 48 | ||||
-rw-r--r-- | chrome/renderer/print_web_view_helper.h | 8 | ||||
-rw-r--r-- | chrome/renderer/print_web_view_helper_linux.cc | 21 | ||||
-rw-r--r-- | chrome/renderer/print_web_view_helper_mac.mm | 15 | ||||
-rw-r--r-- | chrome/renderer/print_web_view_helper_win.cc | 14 |
5 files changed, 55 insertions, 51 deletions
diff --git a/chrome/renderer/print_web_view_helper.cc b/chrome/renderer/print_web_view_helper.cc index 3080c16..ef8e5d5 100644 --- a/chrome/renderer/print_web_view_helper.cc +++ b/chrome/renderer/print_web_view_helper.cc @@ -661,38 +661,32 @@ bool PrintWebViewHelper::RenderPagesForPreview(WebKit::WebFrame* frame, return CreatePreviewDocument(print_settings, frame, node); } -void PrintWebViewHelper::ReportPreviewGenerationTime(base::TimeDelta time, - int pages) { - if (pages <= 0) { +base::TimeTicks PrintWebViewHelper::ReportPreviewPageRenderTime( + base::TimeTicks start_time) { + base::TimeTicks now = base::TimeTicks::Now(); + UMA_HISTOGRAM_TIMES("PrintPreview.RenderPDFPageTime", now - start_time); + return now; +} + +void PrintWebViewHelper::ReportTotalPreviewGenerationTime( + int selected_pages_length, int total_pages, + base::TimeDelta render_time, base::TimeDelta total_time) { + + if (selected_pages_length == 0) + selected_pages_length = total_pages; + + if (selected_pages_length <= 0) { // This shouldn't happen, but this makes sure it doesn't affect the // statistics if it does. return; } - UMA_HISTOGRAM_TIMES("PrintPreview.RenderAndGeneratePDFTime", time); - - if (pages == 1) { - UMA_HISTOGRAM_TIMES( - "PrintPreview.RenderAndGeneratePDFTime.1Page", time); - } else if (pages == 2) { - UMA_HISTOGRAM_TIMES( - "PrintPreview.RenderAndGeneratePDFTime.2Pages", time); - } else if (pages <= 10) { - UMA_HISTOGRAM_TIMES( - "PrintPreview.RenderAndGeneratePDFTime.3-10Pages", time); - } else if (pages <= 25) { - UMA_HISTOGRAM_TIMES( - "PrintPreview.RenderAndGeneratePDFTime.11-25Pages", time); - } else if (pages <= 50) { - UMA_HISTOGRAM_TIMES( - "PrintPreview.RenderAndGeneratePDFTime.26-50Pages", time); - } else if (pages <= 100) { - UMA_HISTOGRAM_TIMES( - "PrintPreview.RenderAndGeneratePDFTime.51-100Pages", time); - } else { - UMA_HISTOGRAM_TIMES( - "PrintPreview.RenderAndGeneratePDFTime.101+Pages", time); - } + UMA_HISTOGRAM_MEDIUM_TIMES("PrintPreview.RenderToPDFTime", + render_time); + UMA_HISTOGRAM_MEDIUM_TIMES("PrintPreview.RenderAndGeneratePDFTime", + total_time); + UMA_HISTOGRAM_MEDIUM_TIMES("PrintPreview.RenderAndGeneratePDFTimeAvgPerPage", + total_time / selected_pages_length); } #if defined(OS_POSIX) diff --git a/chrome/renderer/print_web_view_helper.h b/chrome/renderer/print_web_view_helper.h index db2e280..ed9c8e2 100644 --- a/chrome/renderer/print_web_view_helper.h +++ b/chrome/renderer/print_web_view_helper.h @@ -230,7 +230,13 @@ class PrintWebViewHelper : public RenderViewObserver , bool GetPrintFrame(WebKit::WebFrame** frame); - void ReportPreviewGenerationTime(base::TimeDelta time, int pages); + // This reports the current time - |start_time| as the time to render + // a page and returns the current time. + base::TimeTicks ReportPreviewPageRenderTime(base::TimeTicks start_time); + void ReportTotalPreviewGenerationTime(int selected_pages_length, + int total_pages, + base::TimeDelta render_time, + base::TimeDelta total_time); // Script Initiated Printing ------------------------------------------------ diff --git a/chrome/renderer/print_web_view_helper_linux.cc b/chrome/renderer/print_web_view_helper_linux.cc index 6793e4c..08042b9 100644 --- a/chrome/renderer/print_web_view_helper_linux.cc +++ b/chrome/renderer/print_web_view_helper_linux.cc @@ -166,6 +166,7 @@ bool PrintWebViewHelper::RenderPages(const PrintMsg_PrintPages_Params& params, return false; base::TimeTicks begin_time = base::TimeTicks::Now(); + base::TimeTicks page_begin_time = begin_time; PrintMsg_PrintPage_Params page_params; page_params.params = printParams; @@ -174,27 +175,29 @@ bool PrintWebViewHelper::RenderPages(const PrintMsg_PrintPages_Params& params, for (int i = 0; i < *page_count; ++i) { page_params.page_number = i; PrintPageInternal(page_params, canvas_size, frame, metafile); + if (is_preview) { + page_begin_time = ReportPreviewPageRenderTime(page_begin_time); + } } } else { for (size_t i = 0; i < params.pages.size(); ++i) { page_params.page_number = params.pages[i]; PrintPageInternal(page_params, canvas_size, frame, metafile); + if (is_preview) { + page_begin_time = ReportPreviewPageRenderTime(page_begin_time); + } } } - if (is_preview) { - UMA_HISTOGRAM_TIMES("PrintPreview.RenderToPDFTime", - base::TimeTicks::Now() - begin_time); - } + base::TimeDelta render_time = base::TimeTicks::Now() - begin_time; + prep_frame_view.FinishPrinting(); metafile->FinishDocument(); if (is_preview) { - int preview_page_count = params.pages.size(); - if (!preview_page_count) - preview_page_count = *page_count; - ReportPreviewGenerationTime(base::TimeTicks::Now() - begin_time, - preview_page_count); + ReportTotalPreviewGenerationTime(params.pages.size(), *page_count, + render_time, + base::TimeTicks::Now() - begin_time); } return true; } diff --git a/chrome/renderer/print_web_view_helper_mac.mm b/chrome/renderer/print_web_view_helper_mac.mm index 1f1dedb..e46320e 100644 --- a/chrome/renderer/print_web_view_helper_mac.mm +++ b/chrome/renderer/print_web_view_helper_mac.mm @@ -76,11 +76,13 @@ bool PrintWebViewHelper::CreatePreviewDocument( printParams.printable_size.height()); base::TimeTicks begin_time = base::TimeTicks::Now(); + base::TimeTicks page_begin_time = begin_time; if (params.pages.empty()) { for (int i = 0; i < page_count; ++i) { RenderPage(printParams.page_size, content_area, scale_factor, i, frame, &metafile); + page_begin_time = ReportPreviewPageRenderTime(page_begin_time); } } else { for (size_t i = 0; i < params.pages.size(); ++i) { @@ -88,19 +90,18 @@ bool PrintWebViewHelper::CreatePreviewDocument( break; RenderPage(printParams.page_size, content_area, scale_factor, static_cast<int>(params.pages[i]), frame, &metafile); + page_begin_time = ReportPreviewPageRenderTime(page_begin_time); } } - UMA_HISTOGRAM_TIMES("PrintPreview.RenderToPDFTime", - base::TimeTicks::Now() - begin_time); + base::TimeDelta render_time = base::TimeTicks::Now() - begin_time; + prep_frame_view.FinishPrinting(); metafile.FinishDocument(); - int preview_page_count = params.pages.size(); - if (!preview_page_count) - preview_page_count = page_count; - ReportPreviewGenerationTime(base::TimeTicks::Now() - begin_time, - preview_page_count); + ReportTotalPreviewGenerationTime(params.pages.size(), page_count, + render_time, + base::TimeTicks::Now() - begin_time); PrintHostMsg_DidPreviewDocument_Params preview_params; preview_params.data_size = metafile.GetDataSize(); diff --git a/chrome/renderer/print_web_view_helper_win.cc b/chrome/renderer/print_web_view_helper_win.cc index 3849788..8f55288 100644 --- a/chrome/renderer/print_web_view_helper_win.cc +++ b/chrome/renderer/print_web_view_helper_win.cc @@ -143,11 +143,13 @@ bool PrintWebViewHelper::CreatePreviewDocument( print_params.dpi); base::TimeTicks begin_time = base::TimeTicks::Now(); + base::TimeTicks page_begin_time = begin_time; if (params.pages.empty()) { for (int i = 0; i < page_count; ++i) { float scale_factor = shrink; RenderPage(print_params, &scale_factor, i, true, frame, &metafile); + page_begin_time = ReportPreviewPageRenderTime(page_begin_time); } } else { for (size_t i = 0; i < params.pages.size(); ++i) { @@ -156,11 +158,11 @@ bool PrintWebViewHelper::CreatePreviewDocument( float scale_factor = shrink; RenderPage(print_params, &scale_factor, static_cast<int>(params.pages[i]), true, frame, &metafile); + page_begin_time = ReportPreviewPageRenderTime(page_begin_time); } } - UMA_HISTOGRAM_TIMES("PrintPreview.RenderToPDFTime", - base::TimeTicks::Now() - begin_time); + base::TimeDelta render_time = base::TimeTicks::Now() - begin_time; // Ensure that printing has finished before we start cleaning up and // allocating buffers; this causes prep_frame_view to flush anything pending @@ -171,11 +173,9 @@ bool PrintWebViewHelper::CreatePreviewDocument( if (!metafile->FinishDocument()) NOTREACHED(); - int preview_page_count = params.pages.size(); - if (!preview_page_count) - preview_page_count = page_count; - ReportPreviewGenerationTime(base::TimeTicks::Now() - begin_time, - preview_page_count); + ReportTotalPreviewGenerationTime(params.pages.size(), page_count, + render_time, + base::TimeTicks::Now() - begin_time); // Get the size of the compiled metafile. uint32 buf_size = metafile->GetDataSize(); |