diff options
author | mbelshe@google.com <mbelshe@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-28 01:08:22 +0000 |
---|---|---|
committer | mbelshe@google.com <mbelshe@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-28 01:08:22 +0000 |
commit | e7f6a5a0487f9090384efa02ddc5395fc889f6cc (patch) | |
tree | 9b074a2938ac7556bd97f1b70024977a8fc780b7 /net/flip | |
parent | 9b01080eaf634ced669e506fdfc1fffeadd8a00f (diff) | |
download | chromium_src-e7f6a5a0487f9090384efa02ddc5395fc889f6cc.zip chromium_src-e7f6a5a0487f9090384efa02ddc5395fc889f6cc.tar.gz chromium_src-e7f6a5a0487f9090384efa02ddc5395fc889f6cc.tar.bz2 |
Add histograms for measuring stream performance.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/519005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@35293 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/flip')
-rwxr-xr-x | net/flip/flip_stream.cc | 43 | ||||
-rwxr-xr-x | net/flip/flip_stream.h | 11 |
2 files changed, 53 insertions, 1 deletions
diff --git a/net/flip/flip_stream.cc b/net/flip/flip_stream.cc index f283241..b3d0978 100755 --- a/net/flip/flip_stream.cc +++ b/net/flip/flip_stream.cc @@ -28,7 +28,10 @@ FlipStream::FlipStream(FlipSession* session, flip::FlipStreamId stream_id, user_buffer_(NULL), user_buffer_len_(0), cancelled_(false), - load_log_(log) {} + load_log_(log), + send_bytes_(0), + recv_bytes_(0), + histograms_recorded_(false) {} FlipStream::~FlipStream() { DLOG(INFO) << "Deleting FlipStream for stream " << stream_id_; @@ -98,6 +101,8 @@ int FlipStream::ReadResponseBody( } bytes_read += bytes_to_copy; } + if (bytes_read > 0) + recv_bytes_ += bytes_read; return bytes_read; } else if (response_complete_) { return response_status_; @@ -129,6 +134,8 @@ int FlipStream::SendRequest(UploadDataStream* upload_data, delete upload_data; } + send_time_ = base::TimeTicks::Now(); + DCHECK_EQ(io_state_, STATE_NONE); if (!pushed_) io_state_ = STATE_SEND_HEADERS; @@ -157,6 +164,8 @@ void FlipStream::OnResponseReceived(const HttpResponseInfo& response) { *response_ = response; // TODO(mbelshe): avoid copy. DCHECK(response_->headers); + recv_first_byte_time_ = base::TimeTicks::Now(); + if (io_state_ == STATE_NONE) { CHECK(pushed_); } else if (io_state_ == STATE_READ_HEADERS_COMPLETE) { @@ -184,6 +193,10 @@ bool FlipStream::OnDataReceived(const char* data, int length) { return false; } + if (length > 0) + recv_bytes_ += length; + recv_last_byte_time_ = base::TimeTicks::Now(); + // A zero-length read means that the stream is being closed. if (!length) { metrics_.StopStream(); @@ -224,6 +237,10 @@ bool FlipStream::OnDataReceived(const char* data, int length) { void FlipStream::OnWriteComplete(int status) { // TODO(mbelshe): Check for cancellation here. If we're cancelled, we // should discontinue the DoLoop. + + if (status > 0) + send_bytes_ += status; + DoLoop(status); } @@ -234,6 +251,8 @@ void FlipStream::OnClose(int status) { if (user_callback_) DoCallback(status); + + UpdateHistograms(); } int FlipStream::DoLoop(int result) { @@ -391,4 +410,26 @@ int FlipStream::DoReadBodyComplete(int result) { return ERR_IO_PENDING; } +void FlipStream::UpdateHistograms() { + if (histograms_recorded_) + return; + + histograms_recorded_ = true; + + // We need all timers to be filled in, otherwise metrics can be bogus. + if (send_time_.is_null() || recv_first_byte_time_.is_null() || + recv_last_byte_time_.is_null()) + return; + + UMA_HISTOGRAM_TIMES("Net.SpdyStreamTimeToFirstByte", + recv_first_byte_time_ - send_time_); + UMA_HISTOGRAM_TIMES("Net.SpdyStreamDownloadTime", + recv_last_byte_time_ - recv_first_byte_time_); + UMA_HISTOGRAM_TIMES("Net.SpdyStreamTime", + recv_last_byte_time_ - send_time_); + + UMA_HISTOGRAM_COUNTS("Net.SpdySendBytes", send_bytes_); + UMA_HISTOGRAM_COUNTS("Net.SpdyRecvBytes", recv_bytes_); +} + } // namespace net diff --git a/net/flip/flip_stream.h b/net/flip/flip_stream.h index 4c4cc33..f38e33f 100755 --- a/net/flip/flip_stream.h +++ b/net/flip/flip_stream.h @@ -156,6 +156,10 @@ class FlipStream : public base::RefCounted<FlipStream> { int DoReadBody(); int DoReadBodyComplete(int result); + // Update the histograms. Can safely be called repeatedly, but should only + // be called after the stream has completed. + void UpdateHistograms(); + flip::FlipStreamId stream_id_; std::string path_; int priority_; @@ -188,6 +192,13 @@ class FlipStream : public base::RefCounted<FlipStream> { scoped_refptr<LoadLog> load_log_; + base::TimeTicks send_time_; + base::TimeTicks recv_first_byte_time_; + base::TimeTicks recv_last_byte_time_; + int send_bytes_; + int recv_bytes_; + bool histograms_recorded_; + DISALLOW_COPY_AND_ASSIGN(FlipStream); }; |