简体   繁体   English

如何记录页面生成时间和针对Silverstripe的MySQL查询数量

[英]How to log page generation time and number of MySQL queries for Silverstripe

We are working on a large Silverstripe website which has a large database (700,000+ rows on one table). 我们正在一个大型Silverstripe网站上工作,该网站具有大型数据库(一张桌子上有700,000多行)。 There are issues with hosting performance which are hard to quantify so I'm looking for ways of measuring the page generation time and how many SQL queries are being used to generate each page. 托管性能存在一些难以量化的问题,因此我正在寻找一种方法来衡量页面生成时间以及用于生成每个页面的SQL查询数量。

For a past SS project I hacked the core code to record the pageload time in milliseconds, counting the number of SQL queries, and write to a CSV file. 对于过去的SS项目,我破解了核心代码,以毫秒为单位记录页面加载时间,计算SQL查询的数量,然后写入CSV文件。

However I'd really like to avoid changing the core code and was wondering if there are other options/ modules out there that do a similar thing. 但是,我真的很想避免更改核心代码,并且想知道是否还有其他类似的选项/模块。

Ideally I'd like a CSV which looks something like this Timestamp, URL, milliseconds, queries 2016/11/10 14:10:00, http://www.example.com/url1, 345, 67 2016/11/10 14:10:05, http://www.example.com/url2, 123, 45 理想情况下,我想要一个看起来像这样的CSV Timestamp, URL, milliseconds, queries 2016/11/10 14:10:00, http://www.example.com/url1, 345, 67 2016/11/10 14:10:05, http://www.example.com/url2, 123, 45

There is also a debug toolbar for SilverStripe , we also mentioned it in our talk about debugging SilverStripe at the last StripeConEU. 还有一个SilverStripe调试工具栏 ,我们在最后一个StripeConEU上有关调试SilverStripe讨论中也提到了它。

You can install it to your require-dev section using composer: 您可以使用composer将其安装到require-dev部分:

composer require --dev lekoala/silverstripe-debugbar  

and of course flush after installation. 并且在安装后当然要冲洗。

Then you see a small SilverStripe logo at the bottom left which hides the actual debug bar: 然后,您会在左下方看到一个小的SilverStripe徽标,该徽标隐藏了实际的调试栏:

运行中的SilverStripe调试栏的屏幕截图

With this you can (beside much useful information) display all queries and also filter for duplicate queries only. 这样,您可以(除了有用的信息之外)显示所有查询,还可以仅过滤重复查询。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM