How to log page generation statistics?

I want to get some statistics about page generation. Such a number, list and time of SQL queries, PHP execution time, using cache, memory usage etc.
I was trying to enable SQL log, but NC creates lots of parallel requests and all queries puts in one log. So it’s becomes almost useless.
Is it way to get page generation statistics per request? It’s helps to better understand what happens inside and find ways to optimization.

Why don’t you use firebug in firefox or the debugging-funktion of chrome?

Firebug it’s clients logging. I’m talking about server-generated log. FB knows nothing about SQL-queries (even don’t knows using DB at server-side or not).

Thats right…
…but it shows you what wastes the most time.

And what next? OK, you know that page mydomain.com/some_url generates 3s instead of 0.2s. So how to define reason? Maybe it’s some heavy SQL queries, maybe it’s SQL in cycle, maybe it’s a slow disk operation, maybe remote connection… You absolutely have no idea about reasons. And you can’t enable debugging mode at working server.
Nextcloud - is a big complex system. It’s needs built-in debugging tools. That’s what I say.