Let's instrument the response time before writting the template
This commit is contained in:
parent
5517da6a69
commit
5eca3843cc
1 changed files with 7 additions and 2 deletions
|
@ -26,10 +26,13 @@ type handler struct {
|
|||
template *Template
|
||||
hostname string
|
||||
ro bool
|
||||
t1 time.Time
|
||||
}
|
||||
|
||||
func (h handler) load(tmpl string, data interface{}) {
|
||||
var err error
|
||||
|
||||
h.t1 = time.Now()
|
||||
fmt := h.r.FormValue("fmt")
|
||||
switch fmt {
|
||||
case "rss":
|
||||
|
@ -91,8 +94,10 @@ func (sg StatsGatherer) Gather(function func(handler)) func(http.ResponseWriter,
|
|||
|
||||
t0 := time.Now()
|
||||
function(h)
|
||||
t1 := time.Now()
|
||||
sg.channel <- statsRequest{r, t1.Sub(t0)}
|
||||
if h.t1.IsZero() {
|
||||
h.t1 = time.Now()
|
||||
}
|
||||
sg.channel <- statsRequest{r, h.t1.Sub(t0)}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Reference in a new issue