diff options
author | fbarchard@chromium.org <fbarchard@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-21 21:30:24 +0000 |
---|---|---|
committer | fbarchard@chromium.org <fbarchard@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-21 21:30:24 +0000 |
commit | e6676af22ae37bd1716389b2ef3396d5f4b72a8e (patch) | |
tree | f20459f4c561c9fa21e534b14b1de46b17f824b8 /media | |
parent | 0ff224d9d6753bd8f0a9e99ddea2f96b3e264057 (diff) | |
download | chromium_src-e6676af22ae37bd1716389b2ef3396d5f4b72a8e.zip chromium_src-e6676af22ae37bd1716389b2ef3396d5f4b72a8e.tar.gz chromium_src-e6676af22ae37bd1716389b2ef3396d5f4b72a8e.tar.bz2 |
Timing code for measuring DLL load performance.
BUG=18466
TEST=reduce DLL sizes with -O2 and other options, and test performance with this code.
Review URL: http://codereview.chromium.org/165039
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@24017 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media')
-rw-r--r-- | media/base/media_win.cc | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/media/base/media_win.cc b/media/base/media_win.cc index 31bfe43..975a301 100644 --- a/media/base/media_win.cc +++ b/media/base/media_win.cc @@ -10,6 +10,23 @@ #include "base/logging.h" #include "base/path_service.h" +// Enable timing code by turning on TESTING macro. +//#define TESTING 1 + +#ifdef TESTING +#include "base/string_util.h" +#include "base/time.h" + +namespace { +// Fetch current time as milliseconds. +// Return as double for high duration and precision. +// TODO(fbarchard): integrate into base/time.h +static inline double GetTime() { + return base::TimeTicks::HighResNow().ToInternalValue() * (1.0 / 1000.0); +} +} +#endif + namespace media { namespace { @@ -49,9 +66,20 @@ bool InitializeMediaLibrary(const FilePath& base_path) { HMODULE libs[arraysize(path_keys)] = {NULL}; for (size_t i = 0; i < arraysize(path_keys); ++i) { FilePath path = base_path.Append(GetDLLName(path_keys[i])); - libs[i] = LoadLibrary(path.value().c_str()); +#ifdef TESTING + double dll_loadtime_start = GetTime(); +#endif + const wchar_t* cpath = path.value().c_str(); + libs[i] = LoadLibrary(cpath); if (!libs[i]) break; +#ifdef TESTING + double dll_loadtime_end = GetTime(); + std::wstring outputbuf = StringPrintf(L"DLL loadtime %5.2f ms, %ls\n", + dll_loadtime_end - dll_loadtime_start, + cpath); + OutputDebugStringW(outputbuf.c_str()); +#endif } // Check that we loaded all libraries successfully. We only need to check the |