Thông tin Drupal Performance với PHPStorm and Xdebug

Thông tin Drupal Performance với PHPStorm and Xdebug

Profiling is about measuring the performance of PHP code, at least when we are talking about Drupal and Xdebug. You might need to profile your site or app if you work at a firm where performance is highly scrutinized, or if you are having problems getting a migration to complete. Whatever the reason, if you have been tasked with analyzing the performance of your Drupal codebase, profiling is one great way of doing so. Note that Xdebug’s profiler does not track memory usage. If you want to know more about memory performance tracking you should check out Xdebug’s execution trace features.

Alright then lets get started! 

Whoa there cowboy! First you need to know that the act of profiling your code is itself taking resources to accomplish. The more work your code does, the more information that the profiler stores; file sizes for these logs can get very big very quickly. You have been warned. To get going with profiling Drupal in PHPStorm and Xdebug you need:

To setup your environment, edit your php.ini file and add the following lines:

xdebug.profiler_output_dir=/tmp/profiler/
xdebug.profiler_enable=on
xdebug.profiler_trigger=on
xdebug.profiler_append=on

Depending on what you are testing and how, you may want to adjust the settings for your site. For instance, if you are using Drush to run a migration, you can’t start the profiler on-demand, and that affects the profiler_trigger setting. For my dev site I used the php.ini config you see above and simply added a URL parameter “XDEBUG_PROFILE=on” to my site’s url; this starts Xdebug profiling from the browser.

To give you an idea of what is possible, lets profile the work required to view a simple Drupal node. To profile the node view I visited http://profiler.loc/node/48581?XDEBUG_PROFILE=on in my browser. I didn’t see any flashing lights or hear bells and whistles, but I should have a binary file that PHPStorm can inspect, located in the path I setup in my php.ini profiler_output_dir directive.

profiler_url

Finally lets look at all of our hard work! In PHPStorm navigate to Tools->Analyze Xdebug Profile Snapshot. Browse to your profiler output directory and you should see at least one cachgrind.out.%p file (%p refers to the process id the script used). Open the file with the largest process id appended to the end of the filename.

PHPStorm Cachgrind Picker

We are then greeted with a new tab showing the results of the profiler.

PHPStorm Xdebug Profiler

The output shows us the functions called, how many times they were called, and the amount of execution time each function took. Additionally, you can see the hierarchy of all function calls and follow potential bottlenecks down to their roots.

There you have it! Go wild and profile all the things! Just kidding, don’t do that.

Bạn thấy bài viết này như thế nào?: 
No votes yet
Ảnh của Tommy Tran

Tommy owner Express Magazine

Drupal Developer having 9+ year experience, implementation and having strong knowledge of technical specifications, workflow development. Ability to perform effectively and efficiently in team and individually. Always enthusiastic and interseted to study new technologies

  • Skype ID: tthanhthuy

Tìm kiếm bất động sản

 

Advertisement

 

jobsora

Dich vu khu trung tphcm

Dich vu diet chuot tphcm

Dich vu diet con trung

Quảng Cáo Bài Viết

 
Drupal 8: Thủ thuật làm cho Drupal Content Types của bạn đẹp hơn

Drupal 8: Thủ thuật làm cho Drupal Content Types của bạn đẹp hơn

Besides Title, the most common field label found on a content type form is Body. Of course, this is where you place the body of your content

Phần mềm theo dõi điện thoại: Đe dọa nghiêm trọng bí mật đời tư

Phần mềm theo dõi điện thoại: Đe dọa nghiêm trọng bí mật đời tư

Điện thoại thông minh đời mới nhất như: iPhone, Nokia, Sam Sung, LG… đều có thể bị cài đặt phần mềm theo dõi để trộm cắp thông tin. Những lời chào mời mua phần mềm theo dõi điện thoại được đăng tải rất công khai trên mạng.

Google Mua Thêm 217 Bằng Sáng Chế Từ IBM

Google Mua Thêm 217 Bằng Sáng Chế Từ IBM

Theo thông tin có được từ blog SEO by the Sea mới đây thì Google vừa hoàn thành thương vụ mua lại 217 bằng sáng chế từ IBM với....

Công ty diệt chuột T&C

 

Diet con trung