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
|
template *Template
|
||||||
hostname string
|
hostname string
|
||||||
ro bool
|
ro bool
|
||||||
|
t1 time.Time
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h handler) load(tmpl string, data interface{}) {
|
func (h handler) load(tmpl string, data interface{}) {
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
|
h.t1 = time.Now()
|
||||||
fmt := h.r.FormValue("fmt")
|
fmt := h.r.FormValue("fmt")
|
||||||
switch fmt {
|
switch fmt {
|
||||||
case "rss":
|
case "rss":
|
||||||
|
@ -91,8 +94,10 @@ func (sg StatsGatherer) Gather(function func(handler)) func(http.ResponseWriter,
|
||||||
|
|
||||||
t0 := time.Now()
|
t0 := time.Now()
|
||||||
function(h)
|
function(h)
|
||||||
t1 := time.Now()
|
if h.t1.IsZero() {
|
||||||
sg.channel <- statsRequest{r, t1.Sub(t0)}
|
h.t1 = time.Now()
|
||||||
|
}
|
||||||
|
sg.channel <- statsRequest{r, h.t1.Sub(t0)}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Reference in a new issue