benbjohnson/ego

Render time support?

mperham opened this issue · 2 comments

Has anyone added or know how to add rendering time output for templates? I have some slow pages and it would be a huge benefit to see something like:

<!-- foo.ego in 43.1234ms -->

in the page source. It would allow me to narrow down view performance issues to a specific template very quickly.

@mperham Are you mainly wanting timings of nested templates? That could be an easy hook to add to the code generation.

Another option is you can use go tool pprof to see the aggregate render times for each template.

Yes. I guess having timings within a tightly nested loop or popular component wouldn't be useful but I don't have those issues. Even if I have to opt-in for timings, it's all good.

I just spent several hours trying to use pprof on macOS to figure out the slow rendering and its output was unusable. Maybe it only works well on Linux? Turns out I had a connection pool size of 20 and 60 goroutines all fighting for those connections, thus the delays.