2

I want to know what functions are being called and what time each request is taking for an application which is running on apache.

Is there any tool or any other way where i can get this data.
I also want to know how much time each function is taking.

The application is running it cannot be stopped.
So i need to get the details in the running environment itself.
Thanks in advance.

ajreal
  • 46,720
  • 11
  • 89
  • 119
gaurav
  • 149
  • 1
  • 2
  • 11
  • Question is ambigious, are you referring profiling apache internal function calls or the web pages running on apache ? And any programming language involved? – ajreal Nov 23 '10 at 08:58
  • i want to profile internal functions call.Programming language is PHP and database is Mysql – gaurav Nov 23 '10 at 10:18

4 Answers4

3

One of the most used industry tools for this is: http://www.xdebug.org/

I have used it religiously for a long time now! From it's front-page it does the following:

"The Xdebug extension helps you debugging your script by providing a lot of valuable debug information. The debug information that Xdebug can provide includes the following:

* stack traces and function traces in error messages with:
      o full parameter display for user defined functions
      o function name, file name and line indications
      o support for member functions
* memory allocation
* protection for infinite recursions"
Brian
  • 8,418
  • 2
  • 25
  • 32
1

Xdebug can write a profiling file that you can analyze in kcachegrind or wincachegrind.

AndreKR
  • 32,613
  • 18
  • 106
  • 168
1

It depends on whether you want active or passive profiling.

Passive tools such as New Relic work silently in the background and collect a little information about all requests by sacrificing a small amount of compute resources. These generally have more information regarding the entire server stack. These are typically used for production environments, which sounds like what you require.

Active profilers are used for development and will run just once per request, collecting a lot of information specifically about the part of the application you are working on at the cost of a large performance hit. The most common PHP active profiler is probably Xdebug.

Ways to analyse the data from Xdebug:

NOTE: If you use a virtual machine, vagrant, docker etc make sure you set the output dir to a shared volume, accessible outside of the virtual machine

e.g.

(php.ini) xdebug.profiler_output_dir = "/project_root/tmp"

If you use PHPStorm:

  • Tools > Analyse Xdebug Profiler snapshot...

For those using Xdebug on MacOS:

Using homebrew install qcachegrind and AppViz

  • brew install qcachegrind

  • brew install graphviz

Then run it from command line:

qcachegrind cachegrind.out.1394

OR just run qcachegrind and open the cachegrind file generated by xdebug using the GUI navigator

Community
  • 1
  • 1
Jordan Whitfield
  • 1,413
  • 15
  • 17
0

There are couple of PHP profiling tools,
such as

ajreal
  • 46,720
  • 11
  • 89
  • 119