diff options
author | jar@chromium.org <jar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-10 16:35:47 +0000 |
---|---|---|
committer | jar@chromium.org <jar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-10 16:35:47 +0000 |
commit | 85632fab9c8f30b4651f06fd75e1ba5881226e6c (patch) | |
tree | 45e5c31224f7b5951fbefb387da4f3fbf7acbd85 | |
parent | 99aae10b7b9cd4c1e08bb4e978c822483864e331 (diff) | |
download | chromium_src-85632fab9c8f30b4651f06fd75e1ba5881226e6c.zip chromium_src-85632fab9c8f30b4651f06fd75e1ba5881226e6c.tar.gz chromium_src-85632fab9c8f30b4651f06fd75e1ba5881226e6c.tar.bz2 |
Switch to using TimeTicks for profiling and histograms
Avoid using wall clock time, which can be changed by the user,
or impacted by Daylight Savings transitions etc.
BUG=14193
r=eroman
Review URL: http://codereview.chromium.org/1253005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@46821 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | base/spin_wait.h | 6 | ||||
-rw-r--r-- | base/tracked.cc | 10 | ||||
-rw-r--r-- | base/tracked.h | 2 | ||||
-rw-r--r-- | chrome/browser/safe_browsing/safe_browsing_database.cc | 10 | ||||
-rw-r--r-- | chrome/browser/safe_browsing/safe_browsing_database_bloom.cc | 4 | ||||
-rw-r--r-- | chrome/test/chrome_process_util.cc | 8 | ||||
-rw-r--r-- | net/base/file_stream_posix.cc | 5 | ||||
-rw-r--r-- | net/base/file_stream_win.cc | 5 | ||||
-rw-r--r-- | net/disk_cache/block_files.cc | 1 |
9 files changed, 27 insertions, 24 deletions
diff --git a/base/spin_wait.h b/base/spin_wait.h index d6571b7..b1e2045 100644 --- a/base/spin_wait.h +++ b/base/spin_wait.h @@ -35,11 +35,11 @@ (expression)) #define SPIN_FOR_TIMEDELTA_OR_UNTIL_TRUE(delta, expression) do { \ - base::Time start = base::Time::Now(); \ + base::TimeTicks start = base::TimeTicks::Now(); \ const base::TimeDelta kTimeout = delta; \ while (!(expression)) { \ - if (kTimeout < base::Time::Now() - start) { \ - EXPECT_LE((base::Time::Now() - start).InMilliseconds(), \ + if (kTimeout < base::TimeTicks::Now() - start) { \ + EXPECT_LE((base::TimeTicks::Now() - start).InMilliseconds(), \ kTimeout.InMilliseconds()) << "Timed out"; \ break; \ } \ diff --git a/base/tracked.cc b/base/tracked.cc index 34694bb..fdac6d3 100644 --- a/base/tracked.cc +++ b/base/tracked.cc @@ -7,7 +7,7 @@ #include "base/string_util.h" #include "base/tracked_objects.h" -using base::Time; +using base::TimeTicks; namespace tracked_objects { @@ -56,7 +56,9 @@ void Tracked::ResetBirthTime() {} #else -Tracked::Tracked() : tracked_births_(NULL), tracked_birth_time_(Time::Now()) { +Tracked::Tracked() + : tracked_births_(NULL), + tracked_birth_time_(TimeTicks::Now()) { if (!ThreadData::IsActive()) return; SetBirthPlace(Location("NoFunctionName", "NeedToSetBirthPlace", -1)); @@ -66,7 +68,7 @@ Tracked::~Tracked() { if (!ThreadData::IsActive() || !tracked_births_) return; ThreadData::current()->TallyADeath(*tracked_births_, - Time::Now() - tracked_birth_time_); + TimeTicks::Now() - tracked_birth_time_); } void Tracked::SetBirthPlace(const Location& from_here) { @@ -81,7 +83,7 @@ void Tracked::SetBirthPlace(const Location& from_here) { } void Tracked::ResetBirthTime() { - tracked_birth_time_ = Time::Now(); + tracked_birth_time_ = TimeTicks::Now(); } bool Tracked::MissingBirthplace() const { diff --git a/base/tracked.h b/base/tracked.h index c0c3aee..b0be729 100644 --- a/base/tracked.h +++ b/base/tracked.h @@ -116,7 +116,7 @@ class Tracked { // The time this object was constructed. If its life consisted of a long // waiting period, and then it became active, then this value is generally // reset before the object begins it active life. - base::Time tracked_birth_time_; + base::TimeTicks tracked_birth_time_; #endif // TRACK_ALL_TASK_OBJECTS diff --git a/chrome/browser/safe_browsing/safe_browsing_database.cc b/chrome/browser/safe_browsing/safe_browsing_database.cc index aa6a97a..3237b30 100644 --- a/chrome/browser/safe_browsing/safe_browsing_database.cc +++ b/chrome/browser/safe_browsing/safe_browsing_database.cc @@ -9,7 +9,7 @@ #include "chrome/browser/safe_browsing/bloom_filter.h" #include "chrome/browser/safe_browsing/safe_browsing_database_bloom.h" -using base::Time; +using base::TimeTicks; // Filename suffix for the bloom filter. static const FilePath::CharType kBloomFilterFile[] = @@ -47,10 +47,10 @@ void SafeBrowsingDatabase::LoadBloomFilter() { } // We have a bloom filter file, so use that as our filter. - Time before = Time::Now(); + TimeTicks before = TimeTicks::Now(); bloom_filter_ = BloomFilter::LoadFile(bloom_filter_filename_); SB_DLOG(INFO) << "SafeBrowsingDatabase read bloom filter in " - << (Time::Now() - before).InMilliseconds() << " ms"; + << (TimeTicks::Now() - before).InMilliseconds() << " ms"; if (!bloom_filter_.get()) UMA_HISTOGRAM_COUNTS("SB2.FilterReadFail", 1); @@ -64,10 +64,10 @@ void SafeBrowsingDatabase::WriteBloomFilter() { if (!bloom_filter_.get()) return; - Time before = Time::Now(); + TimeTicks before = TimeTicks::Now(); bool write_ok = bloom_filter_->WriteFile(bloom_filter_filename_); SB_DLOG(INFO) << "SafeBrowsingDatabase wrote bloom filter in " << - (Time::Now() - before).InMilliseconds() << " ms"; + (TimeTicks::Now() - before).InMilliseconds() << " ms"; if (!write_ok) UMA_HISTOGRAM_COUNTS("SB2.FilterWriteFail", 1); diff --git a/chrome/browser/safe_browsing/safe_browsing_database_bloom.cc b/chrome/browser/safe_browsing/safe_browsing_database_bloom.cc index 6951e41..8acda7c 100644 --- a/chrome/browser/safe_browsing/safe_browsing_database_bloom.cc +++ b/chrome/browser/safe_browsing/safe_browsing_database_bloom.cc @@ -157,7 +157,7 @@ void SafeBrowsingDatabaseBloom::InsertChunks(const std::string& list_name, if (chunks.empty()) return; - base::Time insert_start = base::Time::Now(); + base::TimeTicks insert_start = base::TimeTicks::Now(); int list_id = safe_browsing_util::GetListId(list_name); ChunkType chunk_type = chunks.front().is_add ? ADD_CHUNK : SUB_CHUNK; @@ -190,7 +190,7 @@ void SafeBrowsingDatabaseBloom::InsertChunks(const std::string& list_name, } } - UMA_HISTOGRAM_TIMES("SB2.ChunkInsert", base::Time::Now() - insert_start); + UMA_HISTOGRAM_TIMES("SB2.ChunkInsert", base::TimeTicks::Now() - insert_start); } void SafeBrowsingDatabaseBloom::DeleteChunks( diff --git a/chrome/test/chrome_process_util.cc b/chrome/test/chrome_process_util.cc index 8e86e60..a3c4d6f 100644 --- a/chrome/test/chrome_process_util.cc +++ b/chrome/test/chrome_process_util.cc @@ -12,8 +12,8 @@ #include "chrome/common/chrome_constants.h" #include "chrome/common/result_codes.h" -using base::Time; using base::TimeDelta; +using base::TimeTicks; void TerminateAllChromeProcesses(base::ProcessId browser_pid) { // Total time the function will wait for chrome processes @@ -38,11 +38,11 @@ void TerminateAllChromeProcesses(base::ProcessId browser_pid) { for (it = handles.begin(); it != handles.end(); ++it) base::KillProcess(*it, ResultCodes::TASKMAN_KILL, false); - const Time start = Time::Now(); + const TimeTicks start = TimeTicks::Now(); for (it = handles.begin(); - it != handles.end() && Time::Now() - start < kExitTimeout; + it != handles.end() && TimeTicks::Now() - start < kExitTimeout; ++it) { - int64 wait_time_ms = (Time::Now() - start).InMilliseconds(); + int64 wait_time_ms = (TimeTicks::Now() - start).InMilliseconds(); base::WaitForSingleProcess(*it, wait_time_ms); } diff --git a/net/base/file_stream_posix.cc b/net/base/file_stream_posix.cc index 65c8e2b..735f2b8 100644 --- a/net/base/file_stream_posix.cc +++ b/net/base/file_stream_posix.cc @@ -223,11 +223,12 @@ FileStream::AsyncContext::~AsyncContext() { // still running the IO task, or the completion callback is queued up on the // MessageLoopForIO, but AsyncContext() got deleted before then. const bool need_to_wait = !background_io_completed_.IsSignaled(); - base::Time start = base::Time::Now(); + base::TimeTicks start = base::TimeTicks::Now(); RunAsynchronousCallback(); if (need_to_wait) { // We want to see if we block the message loop for too long. - UMA_HISTOGRAM_TIMES("AsyncIO.FileStreamClose", base::Time::Now() - start); + UMA_HISTOGRAM_TIMES("AsyncIO.FileStreamClose", + base::TimeTicks::Now() - start); } } } diff --git a/net/base/file_stream_win.cc b/net/base/file_stream_win.cc index 1ad9a34..6a6db90 100644 --- a/net/base/file_stream_win.cc +++ b/net/base/file_stream_win.cc @@ -74,14 +74,15 @@ class FileStream::AsyncContext : public MessageLoopForIO::IOHandler { FileStream::AsyncContext::~AsyncContext() { is_closing_ = true; bool waited = false; - base::Time start = base::Time::Now(); + base::TimeTicks start = base::TimeTicks::Now(); while (callback_) { waited = true; MessageLoopForIO::current()->WaitForIOCompletion(INFINITE, this); } if (waited) { // We want to see if we block the message loop for too long. - UMA_HISTOGRAM_TIMES("AsyncIO.FileStreamClose", base::Time::Now() - start); + UMA_HISTOGRAM_TIMES("AsyncIO.FileStreamClose", + base::TimeTicks::Now() - start); } } diff --git a/net/disk_cache/block_files.cc b/net/disk_cache/block_files.cc index 3161317..3a87731 100644 --- a/net/disk_cache/block_files.cc +++ b/net/disk_cache/block_files.cc @@ -11,7 +11,6 @@ #include "net/disk_cache/cache_util.h" #include "net/disk_cache/file_lock.h" -using base::Time; using base::TimeTicks; namespace { |