From 447baadf9dd279ae3dfb226ba34c75c48f3da930 Mon Sep 17 00:00:00 2001
From: "rvargas@google.com"
 <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98>
Date: Fri, 28 Aug 2009 23:05:46 +0000
Subject: Disk cache: Add a histogram to measure the latency of asynchronous
 IO.

BUG=none
TEST=none

Review URL: http://codereview.chromium.org/178023

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@24829 0039d316-1c4b-4281-b951-d872f2087c98
---
 net/disk_cache/entry_impl.cc | 12 +++++++++---
 net/disk_cache/entry_impl.h  | 21 +++++++++++----------
 2 files changed, 20 insertions(+), 13 deletions(-)

(limited to 'net/disk_cache')

diff --git a/net/disk_cache/entry_impl.cc b/net/disk_cache/entry_impl.cc
index 0f25684..4b650d9 100644
--- a/net/disk_cache/entry_impl.cc
+++ b/net/disk_cache/entry_impl.cc
@@ -29,7 +29,7 @@ class SyncCallback: public disk_cache::FileIOCallback {
  public:
   SyncCallback(disk_cache::EntryImpl* entry, net::IOBuffer* buffer,
                net::CompletionCallback* callback )
-      : entry_(entry), callback_(callback), buf_(buffer) {
+      : entry_(entry), callback_(callback), buf_(buffer), start_(Time::Now()) {
     entry->AddRef();
     entry->IncrementIoCount();
   }
@@ -41,15 +41,18 @@ class SyncCallback: public disk_cache::FileIOCallback {
   disk_cache::EntryImpl* entry_;
   net::CompletionCallback* callback_;
   scoped_refptr<net::IOBuffer> buf_;
+  Time start_;
 
   DISALLOW_EVIL_CONSTRUCTORS(SyncCallback);
 };
 
 void SyncCallback::OnFileIOComplete(int bytes_copied) {
   entry_->DecrementIoCount();
-  entry_->Release();
-  if (callback_)
+  if (callback_) {
+    entry_->ReportIOTime(disk_cache::EntryImpl::kAsyncIO, start_);
     callback_->Run(bytes_copied);
+  }
+  entry_->Release();
   delete this;
 }
 
@@ -880,6 +883,9 @@ void EntryImpl::ReportIOTime(Operation op, const base::Time& start) {
     case kSparseWrite:
       CACHE_UMA(AGE_MS, "SparseWriteTime", 0, start);
       break;
+    case kAsyncIO:
+      CACHE_UMA(AGE_MS, "AsyncIOTime", group, start);
+      break;
     default:
       NOTREACHED();
   }
diff --git a/net/disk_cache/entry_impl.h b/net/disk_cache/entry_impl.h
index 4bb4d04..f5961f9 100644
--- a/net/disk_cache/entry_impl.h
+++ b/net/disk_cache/entry_impl.h
@@ -21,6 +21,14 @@ class EntryImpl : public Entry, public base::RefCounted<EntryImpl> {
   friend class base::RefCounted<EntryImpl>;
   friend class SparseControl;
  public:
+  enum Operation {
+    kRead,
+    kWrite,
+    kSparseRead,
+    kSparseWrite,
+    kAsyncIO
+  };
+
   EntryImpl(BackendImpl* backend, Addr address);
 
   // Entry interface.
@@ -99,18 +107,14 @@ class EntryImpl : public Entry, public base::RefCounted<EntryImpl> {
   // the upgrade tool.
   void SetTimes(base::Time last_used, base::Time last_modified);
 
+  // Generates a histogram for the time spent working on this operation.
+  void ReportIOTime(Operation op, const base::Time& start);
+
  private:
   enum {
      kNumStreams = 3
   };
 
-  enum Operation {
-    kRead,
-    kWrite,
-    kSparseRead,
-    kSparseWrite
-  };
-
   ~EntryImpl();
 
   // Initializes the storage for an internal or external data block.
@@ -166,9 +170,6 @@ class EntryImpl : public Entry, public base::RefCounted<EntryImpl> {
   // actual cleanup.
   void GetData(int index, char** buffer, Addr* address);
 
-  // Generates a histogram for the time spent working on this operation.
-  void ReportIOTime(Operation op, const base::Time& start);
-
   // Logs this entry to the internal trace buffer.
   void Log(const char* msg);
 
-- 
cgit v1.1