diff options
author | tfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-09-17 00:34:38 +0000 |
---|---|---|
committer | tfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-09-17 00:34:38 +0000 |
commit | 9db9c91eb1db09e024449309f0383932eb69a0ed (patch) | |
tree | 4795a8031a5a9e8646fa7b9c7402b5c5daaf4e62 | |
parent | 88dcdb78847445fb487e849d987c15694cf109cb (diff) | |
download | chromium_src-9db9c91eb1db09e024449309f0383932eb69a0ed.zip chromium_src-9db9c91eb1db09e024449309f0383932eb69a0ed.tar.gz chromium_src-9db9c91eb1db09e024449309f0383932eb69a0ed.tar.bz2 |
base: Split logging functions and PerfTimeLogger out of perftimer.h
Soon PerfTimer will move into base/timer/ directory as it is already used by
production code.
This splits the logging stuff into their owns files and also moves
PerfTimeLogger into its own files.
BUG=None
TEST=base_unittests, ipc_perftests, etc...
R=brettw@chromium.org
Review URL: https://chromiumcodereview.appspot.com/23985006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@223486 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | base/base.gyp | 7 | ||||
-rw-r--r-- | base/test/perf_log.cc | 44 | ||||
-rw-r--r-- | base/test/perf_log.h | 24 | ||||
-rw-r--r-- | base/test/perf_test_suite.cc | 11 | ||||
-rw-r--r-- | base/test/perf_time_logger.cc | 27 | ||||
-rw-r--r-- | base/test/perf_time_logger.h | 37 | ||||
-rw-r--r-- | base/test/perftimer.h | 56 | ||||
-rw-r--r-- | chrome/test/perf/url_parse_perftest.cc | 14 | ||||
-rw-r--r-- | chrome_frame/test/perf/chrome_frame_perftest.cc | 12 | ||||
-rw-r--r-- | chrome_frame/test/perf/chrome_frame_perftest.h | 4 | ||||
-rw-r--r-- | chrome_frame/test/perf/silverlight.cc | 22 | ||||
-rw-r--r-- | components/visitedlink/test/visitedlink_perftest.cc | 18 | ||||
-rw-r--r-- | content/browser/net/sqlite_persistent_cookie_store_perftest.cc | 6 | ||||
-rw-r--r-- | ipc/ipc_perftests.cc | 6 | ||||
-rw-r--r-- | media/ffmpeg/ffmpeg_unittest.cc | 14 | ||||
-rw-r--r-- | net/cookies/cookie_monster_perftest.cc | 28 | ||||
-rw-r--r-- | net/disk_cache/disk_cache_perftest.cc | 12 | ||||
-rw-r--r-- | net/proxy/proxy_resolver_perftest.cc | 4 | ||||
-rw-r--r-- | ppapi/proxy/ppp_messaging_proxy_perftest.cc | 4 |
19 files changed, 222 insertions, 128 deletions
diff --git a/base/base.gyp b/base/base.gyp index bf3e261..7c988f3 100644 --- a/base/base.gyp +++ b/base/base.gyp @@ -886,9 +886,14 @@ 'test/null_task_runner.h', 'test/parallel_test_launcher.cc', 'test/parallel_test_launcher.h', + 'test/perf_log.cc', + 'test/perf_log.h', 'test/perf_test_suite.cc', 'test/perf_test_suite.h', + 'test/perf_time_logger.cc', + 'test/perf_time_logger.h', 'test/perftimer.cc', + 'test/perftimer.h', 'test/power_monitor_test_base.cc', 'test/power_monitor_test_base.h', 'test/scoped_locale.cc', @@ -964,10 +969,10 @@ 'type': 'static_library', 'dependencies': [ 'base', + 'test_support_base', '../testing/gtest.gyp:gtest', ], 'sources': [ - 'test/perftimer.cc', 'test/run_all_perftests.cc', ], 'direct_dependent_settings': { diff --git a/base/test/perf_log.cc b/base/test/perf_log.cc new file mode 100644 index 0000000..aaeb26c --- /dev/null +++ b/base/test/perf_log.cc @@ -0,0 +1,44 @@ +// Copyright 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "base/test/perf_log.h" + +#include "base/file_util.h" +#include "base/logging.h" + +namespace base { + +static FILE* perf_log_file = NULL; + +bool InitPerfLog(const FilePath& log_file) { + if (perf_log_file) { + // trying to initialize twice + NOTREACHED(); + return false; + } + + perf_log_file = file_util::OpenFile(log_file, "w"); + return perf_log_file != NULL; +} + +void FinalizePerfLog() { + if (!perf_log_file) { + // trying to cleanup without initializing + NOTREACHED(); + return; + } + file_util::CloseFile(perf_log_file); +} + +void LogPerfResult(const char* test_name, double value, const char* units) { + if (!perf_log_file) { + NOTREACHED(); + return; + } + + fprintf(perf_log_file, "%s\t%g\t%s\n", test_name, value, units); + printf("%s\t%g\t%s\n", test_name, value, units); +} + +} // namespace base diff --git a/base/test/perf_log.h b/base/test/perf_log.h new file mode 100644 index 0000000..5d6ed9f --- /dev/null +++ b/base/test/perf_log.h @@ -0,0 +1,24 @@ +// Copyright 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef BASE_TEST_PERF_LOG_H_ +#define BASE_TEST_PERF_LOG_H_ + +namespace base { + +class FilePath; + +// Initializes and finalizes the perf log. These functions should be +// called at the beginning and end (respectively) of running all the +// performance tests. The init function returns true on success. +bool InitPerfLog(const FilePath& log_path); +void FinalizePerfLog(); + +// Writes to the perf result log the given 'value' resulting from the +// named 'test'. The units are to aid in reading the log by people. +void LogPerfResult(const char* test_name, double value, const char* units); + +} // namespace base + +#endif // BASE_TEST_PERF_LOG_H_ diff --git a/base/test/perf_test_suite.cc b/base/test/perf_test_suite.cc index 86be119..04ebb8b 100644 --- a/base/test/perf_test_suite.cc +++ b/base/test/perf_test_suite.cc @@ -10,13 +10,12 @@ #include "base/path_service.h" #include "base/process/launch.h" #include "base/strings/string_util.h" -#include "base/test/perftimer.h" +#include "base/test/perf_log.h" #include "testing/gtest/include/gtest/gtest.h" namespace base { -PerfTestSuite::PerfTestSuite(int argc, char** argv) : TestSuite(argc, argv) { -} +PerfTestSuite::PerfTestSuite(int argc, char** argv) : TestSuite(argc, argv) {} void PerfTestSuite::Initialize() { TestSuite::Initialize(); @@ -26,7 +25,7 @@ void PerfTestSuite::Initialize() { CommandLine::ForCurrentProcess()->GetSwitchValuePath("log-file"); if (log_path.empty()) { FilePath exe; - PathService::Get(base::FILE_EXE, &exe); + PathService::Get(FILE_EXE, &exe); log_path = exe.ReplaceExtension(FILE_PATH_LITERAL("log")); log_path = log_path.InsertBeforeExtension(FILE_PATH_LITERAL("_perf")); } @@ -34,8 +33,8 @@ void PerfTestSuite::Initialize() { // Raise to high priority to have more precise measurements. Since we don't // aim at 1% precision, it is not necessary to run at realtime level. - if (!base::debug::BeingDebugged()) - base::RaiseProcessToHighPriority(); + if (!debug::BeingDebugged()) + RaiseProcessToHighPriority(); } void PerfTestSuite::Shutdown() { diff --git a/base/test/perf_time_logger.cc b/base/test/perf_time_logger.cc new file mode 100644 index 0000000..c05ba51 --- /dev/null +++ b/base/test/perf_time_logger.cc @@ -0,0 +1,27 @@ +// Copyright 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "base/test/perf_time_logger.h" + +#include "base/test/perf_log.h" + +namespace base { + +PerfTimeLogger::PerfTimeLogger(const char* test_name) + : logged_(false), test_name_(test_name) {} + +PerfTimeLogger::~PerfTimeLogger() { + if (!logged_) + Done(); +} + +void PerfTimeLogger::Done() { + // we use a floating-point millisecond value because it is more + // intuitive than microseconds and we want more precision than + // integer milliseconds + LogPerfResult(test_name_.c_str(), timer_.Elapsed().InMillisecondsF(), "ms"); + logged_ = true; +} + +} // namespace base diff --git a/base/test/perf_time_logger.h b/base/test/perf_time_logger.h new file mode 100644 index 0000000..f23c530 --- /dev/null +++ b/base/test/perf_time_logger.h @@ -0,0 +1,37 @@ +// Copyright 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef BASE_TEST_PERF_TIME_LOGGER_H_ +#define BASE_TEST_PERF_TIME_LOGGER_H_ + +#include <string> + +#include "base/basictypes.h" +#include "base/test/perftimer.h" + +namespace base { + +// Automates calling LogPerfResult for the common case where you want +// to measure the time that something took. Call Done() when the test +// is complete if you do extra work after the test or there are stack +// objects with potentially expensive constructors. Otherwise, this +// class with automatically log on destruction. +class PerfTimeLogger { + public: + explicit PerfTimeLogger(const char* test_name); + ~PerfTimeLogger(); + + void Done(); + + private: + bool logged_; + std::string test_name_; + PerfTimer timer_; + + DISALLOW_COPY_AND_ASSIGN(PerfTimeLogger); +}; + +} // namespace base + +#endif // BASE_TEST_PERF_TIME_LOGGER_H_ diff --git a/base/test/perftimer.h b/base/test/perftimer.h index 1a26cf5..86ee126 100644 --- a/base/test/perftimer.h +++ b/base/test/perftimer.h @@ -5,8 +5,6 @@ #ifndef BASE_TEST_PERFTIMER_H_ #define BASE_TEST_PERFTIMER_H_ -#include <string> - #include "base/basictypes.h" #include "base/time/time.h" @@ -14,25 +12,7 @@ namespace base { class FilePath; } -// ---------------------------------------------------------------------- -// Initializes and finalizes the perf log. These functions should be -// called at the beginning and end (respectively) of running all the -// performance tests. The init function returns true on success. -// ---------------------------------------------------------------------- -bool InitPerfLog(const base::FilePath& log_path); -void FinalizePerfLog(); - -// ---------------------------------------------------------------------- -// LogPerfResult -// Writes to the perf result log the given 'value' resulting from the -// named 'test'. The units are to aid in reading the log by people. -// ---------------------------------------------------------------------- -void LogPerfResult(const char* test_name, double value, const char* units); - -// ---------------------------------------------------------------------- -// PerfTimer -// A simple wrapper around Now() -// ---------------------------------------------------------------------- +// A simple wrapper around Now() class PerfTimer { public: PerfTimer() { @@ -46,40 +26,8 @@ class PerfTimer { private: base::TimeTicks begin_; -}; - -// ---------------------------------------------------------------------- -// PerfTimeLogger -// Automates calling LogPerfResult for the common case where you want -// to measure the time that something took. Call Done() when the test -// is complete if you do extra work after the test or there are stack -// objects with potentially expensive constructors. Otherwise, this -// class with automatically log on destruction. -// ---------------------------------------------------------------------- -class PerfTimeLogger { - public: - explicit PerfTimeLogger(const char* test_name) - : logged_(false), - test_name_(test_name) { - } - - ~PerfTimeLogger() { - if (!logged_) - Done(); - } - void Done() { - // we use a floating-point millisecond value because it is more - // intuitive than microseconds and we want more precision than - // integer milliseconds - LogPerfResult(test_name_.c_str(), timer_.Elapsed().InMillisecondsF(), "ms"); - logged_ = true; - } - - private: - bool logged_; - std::string test_name_; - PerfTimer timer_; + DISALLOW_COPY_AND_ASSIGN(PerfTimer); }; #endif // BASE_TEST_PERFTIMER_H_ diff --git a/chrome/test/perf/url_parse_perftest.cc b/chrome/test/perf/url_parse_perftest.cc index 3aadd06..61ebcb1 100644 --- a/chrome/test/perf/url_parse_perftest.cc +++ b/chrome/test/perf/url_parse_perftest.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "base/test/perftimer.h" +#include "base/test/perf_time_logger.h" #include "testing/gtest/include/gtest/gtest.h" #include "url/gurl.h" #include "url/url_canon.h" @@ -27,7 +27,7 @@ TEST(URLParse, FullURL) { int url_len = static_cast<int>(strlen(url)); url_parse::Parsed parsed; - PerfTimeLogger timer("Full_URL_Parse_AMillion"); + base::PerfTimeLogger timer("Full_URL_Parse_AMillion"); for (int i = 0; i < 1000000; i++) url_parse::ParseStandardURL(url, url_len, &parsed); @@ -53,7 +53,7 @@ TEST(URLParse, TypicalURLParse) { url_parse::Parsed parsed3; // Do this 1/3 of a million times since we do 3 different URLs. - PerfTimeLogger parse_timer("Typical_URL_Parse_AMillion"); + base::PerfTimeLogger parse_timer("Typical_URL_Parse_AMillion"); for (int i = 0; i < 333333; i++) { url_parse::ParseStandardURL(typical_url1, typical_url1_len, &parsed1); url_parse::ParseStandardURL(typical_url2, typical_url2_len, &parsed2); @@ -68,7 +68,7 @@ TEST(URLParse, TypicalURLParseCanon) { url_parse::Parsed parsed2; url_parse::Parsed parsed3; - PerfTimeLogger canon_timer("Typical_Parse_Canon_AMillion"); + base::PerfTimeLogger canon_timer("Typical_Parse_Canon_AMillion"); url_parse::Parsed out_parsed; url_canon::RawCanonOutput<1024> output; for (int i = 0; i < 333333; i++) { // divide by 3 so we get 1M @@ -96,7 +96,7 @@ TEST(URLParse, TypicalURLParseCanonStdString) { url_parse::Parsed parsed2; url_parse::Parsed parsed3; - PerfTimeLogger canon_timer("Typical_Parse_Canon_AMillion"); + base::PerfTimeLogger canon_timer("Typical_Parse_Canon_AMillion"); url_parse::Parsed out_parsed; for (int i = 0; i < 333333; i++) { // divide by 3 so we get 1M url_parse::ParseStandardURL(typical_url1, typical_url1_len, &parsed1); @@ -126,7 +126,7 @@ TEST(URLParse, GURL) { std::string stdurl2(typical_url2); std::string stdurl3(typical_url3); - PerfTimeLogger gurl_timer("Typical_GURL_AMillion"); + base::PerfTimeLogger gurl_timer("Typical_GURL_AMillion"); for (int i = 0; i < 333333; i++) { // divide by 3 so we get 1M GURL gurl1(stdurl1); GURL gurl2(stdurl2); @@ -137,7 +137,7 @@ TEST(URLParse, GURL) { // TODO(darin): chrome code should not depend on WebCore innards TEST(URLParse, KURL) { - PerfTimeLogger timer_kurl("Typical_KURL_AMillion"); + base::PerfTimeLogger timer_kurl("Typical_KURL_AMillion"); for (int i = 0; i < 333333; i++) { // divide by 3 so we get 1M WebCore::WebKitKURL kurl1(typical_url1); WebCore::WebKitKURL kurl2(typical_url2); diff --git a/chrome_frame/test/perf/chrome_frame_perftest.cc b/chrome_frame/test/perf/chrome_frame_perftest.cc index c12c2c9..31f9ac1 100644 --- a/chrome_frame/test/perf/chrome_frame_perftest.cc +++ b/chrome_frame/test/perf/chrome_frame_perftest.cc @@ -1,6 +1,7 @@ // Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. + #include "chrome_frame/test/perf/chrome_frame_perftest.h" #include <atlhost.h> @@ -21,6 +22,7 @@ #include "base/strings/string_util.h" #include "base/strings/stringprintf.h" #include "base/strings/utf_string_conversions.h" +#include "base/test/perf_time_logger.h" #include "base/test/test_file_util.h" #include "base/threading/platform_thread.h" #include "base/time/time.h" @@ -230,8 +232,8 @@ class ChromeFrameActiveXContainerPerf : public ChromeFrameActiveXContainer { ChromeFrameActiveXContainerPerf() {} void CreateControl(bool setup_event_sinks) { - perf_initialize_.reset(new PerfTimeLogger("Fully initialized")); - PerfTimeLogger perf_create("Create Control"); + perf_initialize_.reset(new base::PerfTimeLogger("Fully initialized")); + base::PerfTimeLogger perf_create("Create Control"); HRESULT hr = chromeview_.CreateControl(L"ChromeTab.ChromeFrame"); EXPECT_HRESULT_SUCCEEDED(hr); @@ -272,11 +274,11 @@ class ChromeFrameActiveXContainerPerf : public ChromeFrameActiveXContainer { virtual void BeforeNavigateImpl(const char* url ) { std::string test_name = "Navigate "; test_name += url; - perf_navigate_.reset(new PerfTimeLogger(test_name.c_str())); + perf_navigate_.reset(new base::PerfTimeLogger(test_name.c_str())); } - scoped_ptr<PerfTimeLogger> perf_initialize_; - scoped_ptr<PerfTimeLogger> perf_navigate_; + scoped_ptr<base::PerfTimeLogger> perf_initialize_; + scoped_ptr<base::PerfTimeLogger> perf_navigate_; }; // This class provides common functionality which can be used for most of the diff --git a/chrome_frame/test/perf/chrome_frame_perftest.h b/chrome_frame/test/perf/chrome_frame_perftest.h index 8209846..4fb979c 100644 --- a/chrome_frame/test/perf/chrome_frame_perftest.h +++ b/chrome_frame/test/perf/chrome_frame_perftest.h @@ -1,10 +1,11 @@ // Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. + #ifndef CHROME_FRAME_TEST_PERF_CHROME_FRAME_PERFTEST_H_ #define CHROME_FRAME_TEST_PERF_CHROME_FRAME_PERFTEST_H_ + #include <atlbase.h> -#include "base/test/perftimer.h" #include "testing/gtest/include/gtest/gtest.h" class SimpleModule : public CAtlExeModuleT<SimpleModule> { @@ -16,4 +17,5 @@ class SimpleModule : public CAtlExeModuleT<SimpleModule> { _pAtlModule = NULL; } }; + #endif // CHROME_FRAME_TEST_PERF_CHROME_FRAME_PERFTEST_H_ diff --git a/chrome_frame/test/perf/silverlight.cc b/chrome_frame/test/perf/silverlight.cc index 6ce7a0e..9fb164a 100644 --- a/chrome_frame/test/perf/silverlight.cc +++ b/chrome_frame/test/perf/silverlight.cc @@ -6,6 +6,7 @@ #include <atlwin.h> #include <atlhost.h> +#include "base/test/perf_time_logger.h" #include "base/win/scoped_comptr.h" #include "chrome_frame/test/perf/chrome_frame_perftest.h" @@ -73,13 +74,16 @@ class IXcpControlHostImpl : public IXcpControlHost { // Silverlight container. Supports do-nothing implementation of IXcpControlHost. // Should be extended to do some real movie-or-something download. -class SilverlightContainer : - public IServiceProviderImpl<SilverlightContainer>, - public IXcpControlHostImpl, - public CWindowImpl<SilverlightContainer, CWindow, CWinTraits< - WS_OVERLAPPEDWINDOW | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, - WS_EX_APPWINDOW | WS_EX_WINDOWEDGE> >, - public CComObjectRootEx<CComSingleThreadModel> { +class SilverlightContainer + : public IServiceProviderImpl<SilverlightContainer>, + public IXcpControlHostImpl, + public CWindowImpl< + SilverlightContainer, + CWindow, + CWinTraits<WS_OVERLAPPEDWINDOW | WS_VISIBLE | WS_CLIPCHILDREN | + WS_CLIPSIBLINGS, + WS_EX_APPWINDOW | WS_EX_WINDOWEDGE> >, + public CComObjectRootEx<CComSingleThreadModel> { public: DECLARE_WND_CLASS_EX(L"Silverlight_container", 0, 0) BEGIN_COM_MAP(SilverlightContainer) @@ -141,7 +145,7 @@ TEST(ChromeFramePerf, DISABLED_HostSilverlight2) { CComObjectStackEx<SilverlightContainer> wnd; RECT rc = {0, 0, 800, 600}; wnd.CreateWndAndHost(&rc); - PerfTimeLogger perf_create("Create Silverlight Control2"); + base::PerfTimeLogger perf_create("Create Silverlight Control2"); wnd.CreateControl(); perf_create.Done(); wnd.DestroyWindow(); @@ -153,7 +157,7 @@ TEST(ChromeFramePerf, DISABLED_HostSilverlight) { AtlAxWinInit(); CAxWindow host; RECT rc = {0, 0, 800, 600}; - PerfTimeLogger perf_create("Create Silverlight Control"); + base::PerfTimeLogger perf_create("Create Silverlight Control"); host.Create(NULL, rc, L"AgControl.AgControl", WS_OVERLAPPEDWINDOW | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, WS_EX_APPWINDOW | WS_EX_WINDOWEDGE); diff --git a/components/visitedlink/test/visitedlink_perftest.cc b/components/visitedlink/test/visitedlink_perftest.cc index dfc254ff..afa14ea 100644 --- a/components/visitedlink/test/visitedlink_perftest.cc +++ b/components/visitedlink/test/visitedlink_perftest.cc @@ -10,6 +10,8 @@ #include "base/files/file_path.h" #include "base/memory/shared_memory.h" #include "base/strings/stringprintf.h" +#include "base/test/perf_log.h" +#include "base/test/perf_time_logger.h" #include "base/test/perftimer.h" #include "base/test/test_file_util.h" #include "components/visitedlink/browser/visitedlink_master.h" @@ -83,7 +85,7 @@ TEST_F(VisitedLink, TestAddAndQuery) { NULL, true, true, db_path_, 0); ASSERT_TRUE(master.Init()); - PerfTimeLogger timer("Visited_link_add_and_query"); + base::PerfTimeLogger timer("Visited_link_add_and_query"); // first check without anything in the table CheckVisited(master, added_prefix, 0, add_count); @@ -108,13 +110,13 @@ TEST_F(VisitedLink, TestAddAndQuery) { TEST_F(VisitedLink, TestLoad) { // create a big DB { - PerfTimeLogger table_initialization_timer("Table_initialization"); + base::PerfTimeLogger table_initialization_timer("Table_initialization"); VisitedLinkMaster master(new DummyVisitedLinkEventListener(), NULL, true, true, db_path_, 0); // time init with empty table - PerfTimeLogger initTimer("Empty_visited_link_init"); + base::PerfTimeLogger initTimer("Empty_visited_link_init"); bool success = master.Init(); initTimer.Done(); ASSERT_TRUE(success); @@ -126,7 +128,7 @@ TEST_F(VisitedLink, TestLoad) { FillTable(master, added_prefix, 0, load_test_add_count); // time writing the file out out - PerfTimeLogger flushTimer("Visited_link_database_flush"); + base::PerfTimeLogger flushTimer("Visited_link_database_flush"); master.RewriteFile(); // TODO(maruel): Without calling FlushFileBuffers(master.file_); you don't // know really how much time it took to write the file. @@ -190,10 +192,10 @@ TEST_F(VisitedLink, TestLoad) { cold_sum += cold_load_times[i]; hot_sum += hot_load_times[i]; } - LogPerfResult("Visited_link_cold_load_time", - cold_sum / cold_load_times.size(), "ms"); - LogPerfResult("Visited_link_hot_load_time", - hot_sum / hot_load_times.size(), "ms"); + base::LogPerfResult( + "Visited_link_cold_load_time", cold_sum / cold_load_times.size(), "ms"); + base::LogPerfResult( + "Visited_link_hot_load_time", hot_sum / hot_load_times.size(), "ms"); } } // namespace visitedlink diff --git a/content/browser/net/sqlite_persistent_cookie_store_perftest.cc b/content/browser/net/sqlite_persistent_cookie_store_perftest.cc index 8c4cb8e..e71b56b 100644 --- a/content/browser/net/sqlite_persistent_cookie_store_perftest.cc +++ b/content/browser/net/sqlite_persistent_cookie_store_perftest.cc @@ -10,7 +10,7 @@ #include "base/sequenced_task_runner.h" #include "base/strings/stringprintf.h" #include "base/synchronization/waitable_event.h" -#include "base/test/perftimer.h" +#include "base/test/perf_time_logger.h" #include "base/test/sequenced_worker_pool_owner.h" #include "base/threading/sequenced_worker_pool.h" #include "net/cookies/canonical_cookie.h" @@ -118,7 +118,7 @@ class SQLitePersistentCookieStorePerfTest : public testing::Test { TEST_F(SQLitePersistentCookieStorePerfTest, TestLoadForKeyPerformance) { for (int domain_num = 0; domain_num < 3; ++domain_num) { std::string domain_name(base::StringPrintf("domain_%d.com", domain_num)); - PerfTimeLogger timer( + base::PerfTimeLogger timer( ("Load cookies for the eTLD+1 " + domain_name).c_str()); store_->LoadCookiesForKey(domain_name, base::Bind(&SQLitePersistentCookieStorePerfTest::OnKeyLoaded, @@ -132,7 +132,7 @@ TEST_F(SQLitePersistentCookieStorePerfTest, TestLoadForKeyPerformance) { // Test the performance of load TEST_F(SQLitePersistentCookieStorePerfTest, TestLoadPerformance) { - PerfTimeLogger timer("Load all cookies"); + base::PerfTimeLogger timer("Load all cookies"); Load(); timer.Done(); diff --git a/ipc/ipc_perftests.cc b/ipc/ipc_perftests.cc index c9891dce..e7eeab9 100644 --- a/ipc/ipc_perftests.cc +++ b/ipc/ipc_perftests.cc @@ -12,7 +12,7 @@ #include "base/memory/scoped_ptr.h" #include "base/pickle.h" #include "base/strings/stringprintf.h" -#include "base/test/perftimer.h" +#include "base/test/perf_time_logger.h" #include "base/threading/thread.h" #include "base/time/time.h" #include "ipc/ipc_channel.h" @@ -184,7 +184,7 @@ class PerformanceChannelListener : public IPC::Listener { DCHECK(!perf_logger_.get()); std::string test_name = base::StringPrintf( "IPC_Perf_%dx_%u", msg_count_, static_cast<unsigned>(msg_size_)); - perf_logger_.reset(new PerfTimeLogger(test_name.c_str())); + perf_logger_.reset(new base::PerfTimeLogger(test_name.c_str())); } else { DCHECK_EQ(payload_.size(), reflected_payload.size()); @@ -217,7 +217,7 @@ class PerformanceChannelListener : public IPC::Listener { int count_down_; std::string payload_; EventTimeTracker latency_tracker_; - scoped_ptr<PerfTimeLogger> perf_logger_; + scoped_ptr<base::PerfTimeLogger> perf_logger_; }; TEST_F(IPCChannelPerfTest, Performance) { diff --git a/media/ffmpeg/ffmpeg_unittest.cc b/media/ffmpeg/ffmpeg_unittest.cc index 3557ada..255d2aa 100644 --- a/media/ffmpeg/ffmpeg_unittest.cc +++ b/media/ffmpeg/ffmpeg_unittest.cc @@ -19,7 +19,7 @@ #include "base/path_service.h" #include "base/strings/string_util.h" #include "base/test/perf_test_suite.h" -#include "base/test/perftimer.h" +#include "base/test/perf_time_logger.h" #include "media/base/media.h" #include "media/ffmpeg/ffmpeg_common.h" #include "media/filters/ffmpeg_glue.h" @@ -424,27 +424,27 @@ FFMPEG_TEST_CASE(counting, ogv); TEST_P(FFmpegTest, Perf) { { - PerfTimeLogger timer("Opening file"); + base::PerfTimeLogger timer("Opening file"); OpenFile(GetParam()); } { - PerfTimeLogger timer("Opening codecs"); + base::PerfTimeLogger timer("Opening codecs"); OpenCodecs(); } { - PerfTimeLogger timer("Reading file"); + base::PerfTimeLogger timer("Reading file"); ReadRemainingFile(); } if (has_audio()) { - PerfTimeLogger timer("Decoding audio"); + base::PerfTimeLogger timer("Decoding audio"); DecodeRemainingAudio(); } if (has_video()) { - PerfTimeLogger timer("Decoding video"); + base::PerfTimeLogger timer("Decoding video"); DecodeRemainingVideo(); } { - PerfTimeLogger timer("Seeking to zero"); + base::PerfTimeLogger timer("Seeking to zero"); SeekTo(0); } } diff --git a/net/cookies/cookie_monster_perftest.cc b/net/cookies/cookie_monster_perftest.cc index 8187bcb..2bc0be8 100644 --- a/net/cookies/cookie_monster_perftest.cc +++ b/net/cookies/cookie_monster_perftest.cc @@ -8,7 +8,7 @@ #include "base/message_loop/message_loop.h" #include "base/strings/string_util.h" #include "base/strings/stringprintf.h" -#include "base/test/perftimer.h" +#include "base/test/perf_time_logger.h" #include "net/cookies/canonical_cookie.h" #include "net/cookies/cookie_monster.h" #include "net/cookies/cookie_monster_store_test.h" @@ -97,7 +97,7 @@ class GetCookiesCallback : public BaseCallback { TEST(ParsedCookieTest, TestParseCookies) { std::string cookie(kCookieLine); - PerfTimeLogger timer("Parsed_cookie_parse_cookies"); + base::PerfTimeLogger timer("Parsed_cookie_parse_cookies"); for (int i = 0; i < kNumCookies; ++i) { ParsedCookie pc(cookie); EXPECT_TRUE(pc.IsValid()); @@ -108,7 +108,7 @@ TEST(ParsedCookieTest, TestParseCookies) { TEST(ParsedCookieTest, TestParseBigCookies) { std::string cookie(3800, 'z'); cookie += kCookieLine; - PerfTimeLogger timer("Parsed_cookie_parse_big_cookies"); + base::PerfTimeLogger timer("Parsed_cookie_parse_big_cookies"); for (int i = 0; i < kNumCookies; ++i) { ParsedCookie pc(cookie); EXPECT_TRUE(pc.IsValid()); @@ -126,7 +126,7 @@ TEST_F(CookieMonsterTest, TestAddCookiesOnSingleHost) { SetCookieCallback setCookieCallback; // Add a bunch of cookies on a single host - PerfTimeLogger timer("Cookie_monster_add_single_host"); + base::PerfTimeLogger timer("Cookie_monster_add_single_host"); for (std::vector<std::string>::const_iterator it = cookies.begin(); it != cookies.end(); ++it) { @@ -136,14 +136,14 @@ TEST_F(CookieMonsterTest, TestAddCookiesOnSingleHost) { GetCookiesCallback getCookiesCallback; - PerfTimeLogger timer2("Cookie_monster_query_single_host"); + base::PerfTimeLogger timer2("Cookie_monster_query_single_host"); for (std::vector<std::string>::const_iterator it = cookies.begin(); it != cookies.end(); ++it) { getCookiesCallback.GetCookies(cm.get(), GURL(kGoogleURL)); } timer2.Done(); - PerfTimeLogger timer3("Cookie_monster_deleteall_single_host"); + base::PerfTimeLogger timer3("Cookie_monster_deleteall_single_host"); cm->DeleteAllAsync(CookieMonster::DeleteCallback()); base::MessageLoop::current()->RunUntilIdle(); timer3.Done(); @@ -160,7 +160,7 @@ TEST_F(CookieMonsterTest, TestAddCookieOnManyHosts) { SetCookieCallback setCookieCallback; // Add a cookie on a bunch of host - PerfTimeLogger timer("Cookie_monster_add_many_hosts"); + base::PerfTimeLogger timer("Cookie_monster_add_many_hosts"); for (std::vector<GURL>::const_iterator it = gurls.begin(); it != gurls.end(); ++it) { setCookieCallback.SetCookie(cm.get(), *it, cookie); @@ -169,14 +169,14 @@ TEST_F(CookieMonsterTest, TestAddCookieOnManyHosts) { GetCookiesCallback getCookiesCallback; - PerfTimeLogger timer2("Cookie_monster_query_many_hosts"); + base::PerfTimeLogger timer2("Cookie_monster_query_many_hosts"); for (std::vector<GURL>::const_iterator it = gurls.begin(); it != gurls.end(); ++it) { getCookiesCallback.GetCookies(cm.get(), *it); } timer2.Done(); - PerfTimeLogger timer3("Cookie_monster_deleteall_many_hosts"); + base::PerfTimeLogger timer3("Cookie_monster_deleteall_many_hosts"); cm->DeleteAllAsync(CookieMonster::DeleteCallback()); base::MessageLoop::current()->RunUntilIdle(); timer3.Done(); @@ -229,7 +229,7 @@ TEST_F(CookieMonsterTest, TestDomainTree) { std::string cookie_line = getCookiesCallback.GetCookies(cm.get(), probe_gurl); EXPECT_EQ(5, CountInString(cookie_line, '=')) << "Cookie line: " << cookie_line; - PerfTimeLogger timer("Cookie_monster_query_domain_tree"); + base::PerfTimeLogger timer("Cookie_monster_query_domain_tree"); for (int i = 0; i < kNumCookies; i++) { getCookiesCallback.GetCookies(cm.get(), probe_gurl); } @@ -269,7 +269,7 @@ TEST_F(CookieMonsterTest, TestDomainLine) { cookie_line = getCookiesCallback.GetCookies(cm.get(), probe_gurl); EXPECT_EQ(32, CountInString(cookie_line, '=')); - PerfTimeLogger timer2("Cookie_monster_query_domain_line"); + base::PerfTimeLogger timer2("Cookie_monster_query_domain_line"); for (int i = 0; i < kNumCookies; i++) { getCookiesCallback.GetCookies(cm.get(), probe_gurl); } @@ -304,7 +304,7 @@ TEST_F(CookieMonsterTest, TestImport) { // Import will happen on first access. GURL gurl("www.google.com"); CookieOptions options; - PerfTimeLogger timer("Cookie_monster_import_from_store"); + base::PerfTimeLogger timer("Cookie_monster_import_from_store"); getCookiesCallback.GetCookies(cm.get(), gurl); timer.Done(); @@ -314,7 +314,7 @@ TEST_F(CookieMonsterTest, TestImport) { TEST_F(CookieMonsterTest, TestGetKey) { scoped_refptr<CookieMonster> cm(new CookieMonster(NULL, NULL)); - PerfTimeLogger timer("Cookie_monster_get_key"); + base::PerfTimeLogger timer("Cookie_monster_get_key"); for (int i = 0; i < kNumCookies; i++) cm->GetKey("www.google.com"); timer.Done(); @@ -375,7 +375,7 @@ TEST_F(CookieMonsterTest, TestGCTimes) { // Trigger the Garbage collection we're allowed. setCookieCallback.SetCookie(cm.get(), gurl, cookie_line); - PerfTimeLogger timer((std::string("GC_") + test_case.name).c_str()); + base::PerfTimeLogger timer((std::string("GC_") + test_case.name).c_str()); for (int i = 0; i < kNumCookies; i++) setCookieCallback.SetCookie(cm.get(), gurl, cookie_line); timer.Done(); diff --git a/net/disk_cache/disk_cache_perftest.cc b/net/disk_cache/disk_cache_perftest.cc index abf39b9..6adc4bc 100644 --- a/net/disk_cache/disk_cache_perftest.cc +++ b/net/disk_cache/disk_cache_perftest.cc @@ -9,7 +9,7 @@ #include "base/bind_helpers.h" #include "base/hash.h" #include "base/strings/string_util.h" -#include "base/test/perftimer.h" +#include "base/test/perf_time_logger.h" #include "base/test/test_file_util.h" #include "base/threading/thread.h" #include "base/timer/timer.h" @@ -53,7 +53,7 @@ bool TimeWrite(int num_entries, disk_cache::Backend* cache, MessageLoopHelper helper; CallbackTest callback(&helper, true); - PerfTimeLogger timer("Write disk cache entries"); + base::PerfTimeLogger timer("Write disk cache entries"); for (int i = 0; i < num_entries; i++) { TestEntry entry; @@ -107,7 +107,7 @@ bool TimeRead(int num_entries, disk_cache::Backend* cache, const char* message = cold ? "Read disk cache entries (cold)" : "Read disk cache entries (warm)"; - PerfTimeLogger timer(message); + base::PerfTimeLogger timer(message); for (int i = 0; i < num_entries; i++) { disk_cache::Entry* cache_entry; @@ -150,7 +150,7 @@ TEST_F(DiskCacheTest, Hash) { int seed = static_cast<int>(Time::Now().ToInternalValue()); srand(seed); - PerfTimeLogger timer("Hash disk cache keys"); + base::PerfTimeLogger timer("Hash disk cache keys"); for (int i = 0; i < 300000; i++) { std::string key = GenerateKey(true); base::Hash(key); @@ -223,7 +223,7 @@ TEST_F(DiskCacheTest, BlockFilesPerformance) { const int kNumEntries = 60000; disk_cache::Addr* address = new disk_cache::Addr[kNumEntries]; - PerfTimeLogger timer1("Fill three block-files"); + base::PerfTimeLogger timer1("Fill three block-files"); // Fill up the 32-byte block file (use three files). for (int i = 0; i < kNumEntries; i++) { @@ -232,7 +232,7 @@ TEST_F(DiskCacheTest, BlockFilesPerformance) { } timer1.Done(); - PerfTimeLogger timer2("Create and delete blocks"); + base::PerfTimeLogger timer2("Create and delete blocks"); for (int i = 0; i < 200000; i++) { int entry = rand() * (kNumEntries / RAND_MAX + 1); diff --git a/net/proxy/proxy_resolver_perftest.cc b/net/proxy/proxy_resolver_perftest.cc index 1630d9e..12ffd1b 100644 --- a/net/proxy/proxy_resolver_perftest.cc +++ b/net/proxy/proxy_resolver_perftest.cc @@ -7,7 +7,7 @@ #include "base/file_util.h" #include "base/path_service.h" #include "base/strings/string_util.h" -#include "base/test/perftimer.h" +#include "base/test/perf_time_logger.h" #include "net/base/net_errors.h" #include "net/dns/mock_host_resolver.h" #include "net/proxy/proxy_info.h" @@ -130,7 +130,7 @@ class PacPerfSuiteRunner { // Start the perf timer. std::string perf_test_name = resolver_name_ + "_" + script_name; - PerfTimeLogger timer(perf_test_name.c_str()); + base::PerfTimeLogger timer(perf_test_name.c_str()); for (int i = 0; i < kNumIterations; ++i) { // Round-robin between URLs to resolve. diff --git a/ppapi/proxy/ppp_messaging_proxy_perftest.cc b/ppapi/proxy/ppp_messaging_proxy_perftest.cc index 8520c24..666609a 100644 --- a/ppapi/proxy/ppp_messaging_proxy_perftest.cc +++ b/ppapi/proxy/ppp_messaging_proxy_perftest.cc @@ -4,7 +4,7 @@ #include "base/command_line.h" #include "base/strings/string_number_conversions.h" -#include "base/test/perftimer.h" +#include "base/test/perf_time_logger.h" #include "ppapi/c/ppp_messaging.h" #include "ppapi/proxy/ppapi_proxy_test.h" #include "ppapi/proxy/serialized_var.h" @@ -73,7 +73,7 @@ TEST_F(PppMessagingPerfTest, StringPerformance) { } } srand(seed); - PerfTimeLogger logger("PppMessagingPerfTest.StringPerformance"); + base::PerfTimeLogger logger("PppMessagingPerfTest.StringPerformance"); for (int i = 0; i < string_count; ++i) { const std::string test_string(rand() % max_string_size, 'a'); PP_Var host_string = StringVar::StringToPPVar(test_string); |