简体   繁体   English

如何对我的SQL和PHP代码进行基准测试?

[英]How can i benchmark my SQL and PHP code?

I have problems because i don't really know how I can test my code and sql ( mysql ) to see how long SQL queries and PHP functions /code take to run. 我遇到了问题,因为我真的不知道如何测试我的代码和sql(mysql)以查看SQL查询和PHP函数/ code运行多长时间。

Does anyone here know where I can find these tools? 这里有人知道我在哪里可以找到这些工具吗?

For PHP code, you can use xdebug for profiling . 对于PHP代码,可以使用xdebug进行概要分析 You'll need a frontend to read the trace data as well. 您还需要一个前端来读取跟踪数据。 If you're on windows, you can use WinCacheGrind . 如果您使用的是Windows,则可以使用WinCacheGrind For other OS'es you can use either kCacheGrind (Lots of features, but a bit scary for beginners) or WebGrind (Much simpler and nicer looking). 对于其他操作系统,可以使用kCacheGrind (很多功能,但对于初学者来说有点吓人)或WebGrind (更简单,更美观)。

For Mysql, you can use maatkit for profiling multiple queries, and to analyse a specific query, you should use EXPLAIN . 对于Mysql,可以使用maatkit来分析多个查询,并且要分析特定查询,应使用EXPLAIN

This is called profiling. 这称为分析。 XDebug , APD and probably some other packages provide this functionality. XDebugAPD以及其他一些软件包都可以提供此功能。

The search keyword you want is " profiler ". 您想要的搜索关键字是“事件探查器 ”。

There's several PHP profilers out there; 那里有几个PHP分析器。 XDebug , PHPEd Profiler , APD , DBG , and PQP , just to name a few. XDebugPHPEd ProfilerAPDDBGPQP ,仅举几例。

I've used XDebug on several occasions and though it can be a little annoying to get up and running it does a pretty decent job. 我已经在多个场合使用过XDebug,尽管启动并运行它可能有点烦人,但它确实做得不错。 Just follow the installations docs and you should be fine. 只需按照安装文档操作 ,就可以了。

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

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