Let's instrument the response time before writting the template

This commit is contained in:
Las Zenow 2017-06-06 14:31:32 +00:00
parent 5517da6a69
commit 5eca3843cc

View file

@ -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)}
}
}