WordPress. Better way to Get Number of Queries and Page Load Time

Information about database queries, memory consumption and page load time can greatly help any developer and even common user. Lets examine situation when your wordpress theme takes several seconds to load themselves, or while loading something cause a high loading of db. How to identify where is a problem? First of all – check all queries, check memory and then locate bottleneck.
There are dozen plugins which adds data like page loading time or queries count to WP admin panel or show them below footer. You can often find this in the footer of many sites and it may say something like: “db - 80 queries; loading time - 2.2 seconds”.
But in a case of performance and, as we also note it, better understanding of WP engine (how to deal with WP function and so on) we can retrieve all what we need by utilizing our own code.


The easiest way is to paste the following code at the end of footer.php (for your current theme), right before closing