![]() ![]() You'll see the treeview navigation on the left that allows me to drill down into any particular section of the code flow. Here is a screenshot of a sample application with millions of lines of code that was profiled in a matter of seconds: You can use a treeview-like interface to drill down into each section of code to gain more insight into where any performance bottlenecks might be occurring. For example, if your script includes a file that connects to a database, you should see a small amount of time (a couple of milliseconds) to include the file, and a cumulatively larger amount of time that it took overall because of the database connection. Step 3: Analyze the ResultsOpen up KCacheGrind or WinCacheGrind or MacCallGrind (or whatever application you are using to analyze the file) and tell it to load that file.Įach application will have a different layout, but each application should give you the ability to view the amount of time that each step took - both the individual call time and the time it took for that section to complete. In my case, I accessed:ĭ:\Temp\cachegrind.out.8392 (because 8392 was the process ID) When the script ends, you will have a cachegrind-compatible file ready for analyzing. That triggers the code profiler to start. You would simply append the XDEBUG_PROFILE parameter like this: For example, let's say your normal script is accessed like this: Step 2: Generate the Code ProfileOnce XDebug is installed per step 1, all you have to do is run your script and pass XDEBUG_PROFILE=1 as a query parameter. Make sure you restart your web server/service after changing the php.ini file! My php.ini file on Windows looks like this: and you'll get the exact instructions of what you need to do.Īlso, set up your php.ini file with a few options to enable you to turn on profiling on demand and where to put the files that will be generated. There is plenty of documentation available and a lot of help available if you ask for it!įor Windows platforms, just copy and paste the phpinfo() screen contents into this page: Step 1: Install XDebugFear not, this is always the most complex stage, but it's not too bad. It's a very simple process and can be set up from beginning to end in 3 steps: This resulting cachegrind file is pretty difficult to read without any sort of tools, so we use some existing, free tools to read the cachegrind files for us and present a much easier-to-use interface for seeing how our script performed. The script itself should run exactly as you would normally run it, so that the profiling process is virtually invisible. The concept is that you can have PHP (via an extension called XDebug) keep track of how long it took for every single line of code in a script to run, and to dump that information into a specially-formatted file called a cachegrind file. ![]() It's a bit of an obscure name, but stems from how it was originally used. You need help, and it not only exists, but it's fairly easy to get! You've gone through all the steps you can think of to figure out what is wrong, or it's just too complex of an application. Let's say you have a PHP script that is performing slow. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |