Page Speed Optimization Libraries  1.13.35.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
request_timing_info.h
Go to the documentation of this file.
1 /*
2  * Copyright 2012 Google Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http:///www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
18 
19 #ifndef PAGESPEED_OPT_LOGGING_REQUEST_TIMING_INFO_H_
20 #define PAGESPEED_OPT_LOGGING_REQUEST_TIMING_INFO_H_
21 
23 
24 namespace net_instaweb {
25 
26 class AbstractMutex;
27 class Timer;
28 
44  public:
48  RequestTimingInfo(Timer* timer, AbstractMutex* mutex);
49 
53  void RequestStarted();
54 
57  void ProcessingStarted() { SetToNow(&processing_start_ts_ms_); }
58 
60  void ParsingStarted() { SetToNow(&parsing_start_ts_ms_); }
61 
63  void FirstByteReturned();
64 
67  SetToNow(&pcache_lookup_start_ts_ms_);
68  }
69 
71  void PropertyCacheLookupFinished() { SetToNow(&pcache_lookup_end_ts_ms_); }
72 
75  void RequestFinished() { SetToNow(&end_ts_ms_); }
76 
82  void FetchStarted();
83  void FetchHeaderReceived();
84  void FetchFinished();
85 
88  void SetHTTPCacheLatencyMs(int64 latency_ms);
89  void SetL2HTTPCacheLatencyMs(int64 latency_ms);
90 
92  int64 GetElapsedMs() const;
93 
95  bool GetTimeToStartProcessingMs(int64* elapsed_ms) const {
96  return GetTimeFromStart(processing_start_ts_ms_, elapsed_ms);
97  }
98 
103  bool GetProcessingElapsedMs(int64* elapsed_ms) const;
104 
106  bool GetTimeToPropertyCacheLookupStartMs(int64* elapsed_ms) const {
107  return GetTimeFromStart(pcache_lookup_start_ts_ms_, elapsed_ms);
108  }
109 
111  bool GetTimeToPropertyCacheLookupEndMs(int64* elapsed_ms) const {
112  return GetTimeFromStart(pcache_lookup_end_ts_ms_, elapsed_ms);
113  }
114 
116  bool GetHTTPCacheLatencyMs(int64* latency_ms) const;
117  bool GetL2HTTPCacheLatencyMs(int64* latency_ms) const;
118 
120  bool GetTimeToStartFetchMs(int64* elapsed_ms) const;
121 
123  bool GetFetchHeaderLatencyMs(int64* latency_ms) const;
124 
126  bool GetFetchLatencyMs(int64* latency_ms) const;
127 
130  bool GetTimeToFirstByte(int64* latency_ms) const;
131 
133  bool GetTimeToStartParseMs(int64* elapsed_ms) const {
134  return GetTimeFromStart(parsing_start_ts_ms_, elapsed_ms);
135  }
136 
137  int64 init_ts_ms() const { return init_ts_ms_; }
138 
139  int64 start_ts_ms() const { return start_ts_ms_; }
140 
141  private:
142  int64 NowMs() const;
143 
145  void SetToNow(int64* ts_ms) const;
146 
149  bool GetTimeFromStart(int64 ts_ms, int64* elapsed_ms) const;
150 
151  Timer* timer_;
152 
158  int64 init_ts_ms_;
159  int64 start_ts_ms_;
160  int64 processing_start_ts_ms_;
161  int64 pcache_lookup_start_ts_ms_;
162  int64 pcache_lookup_end_ts_ms_;
163  int64 parsing_start_ts_ms_;
164  int64 end_ts_ms_;
165 
166  AbstractMutex* mu_;
167  int64 fetch_start_ts_ms_;
169  int64 fetch_header_ts_ms_;
170  int64 fetch_end_ts_ms_;
171  int64 first_byte_ts_ms_;
172 
174  int64 http_cache_latency_ms_;
175  int64 l2http_cache_latency_ms_;
176 
177 
178 };
179 
180 }
181 
182 #endif
void FirstByteReturned()
Called when the first byte is sent back to the user.
bool GetHTTPCacheLatencyMs(int64 *latency_ms) const
HTTP Cache latencies.
void ProcessingStarted()
Definition: request_timing_info.h:57
bool GetTimeToPropertyCacheLookupEndMs(int64 *elapsed_ms) const
Milliseconds from request start to pcache lookup end.
Definition: request_timing_info.h:111
void PropertyCacheLookupFinished()
This should be called when a PropertyCache lookup completes.
Definition: request_timing_info.h:71
Abstract interface for implementing a mutex.
Definition: abstract_mutex.h:28
bool GetProcessingElapsedMs(int64 *elapsed_ms) const
int64 GetElapsedMs() const
Milliseconds since Init.
bool GetFetchHeaderLatencyMs(int64 *latency_ms) const
Milliseconds from fetch start to header received.
void SetHTTPCacheLatencyMs(int64 latency_ms)
void RequestFinished()
Definition: request_timing_info.h:75
Definition: request_timing_info.h:43
void ParsingStarted()
This should be called if/when HTML parsing begins.
Definition: request_timing_info.h:60
bool GetTimeToStartProcessingMs(int64 *elapsed_ms) const
Milliseconds from request start to processing start.
Definition: request_timing_info.h:95
void PropertyCacheLookupStarted()
This should be called when a PropertyCache lookup is initiated.
Definition: request_timing_info.h:66
bool GetTimeToPropertyCacheLookupStartMs(int64 *elapsed_ms) const
Milliseconds from request start to pcache lookup start.
Definition: request_timing_info.h:106
bool GetFetchLatencyMs(int64 *latency_ms) const
Milliseconds from fetch start to fetch end.
bool GetTimeToStartParseMs(int64 *elapsed_ms) const
Milliseconds from request start to parse start.
Definition: request_timing_info.h:133
bool GetTimeToStartFetchMs(int64 *elapsed_ms) const
Milliseconds from request start to fetch start.
RequestTimingInfo(Timer *timer, AbstractMutex *mutex)
bool GetTimeToFirstByte(int64 *latency_ms) const
Timer interface, made virtual so it can be mocked for tests.
Definition: timer.h:27