preinheimer / xhprof

XHGUI is a GUI for the XHProf PHP extension, using a database backend, and pretty graphs to make it easy to use and interpret.
Other
833 stars 185 forks source link

The database is inserted with same record for the same timsestamp twice #81

Closed Vidzz closed 9 years ago

Vidzz commented 9 years ago

I tried to use this package to profile PHP application. When I tried to open it read the database of what was recorded, there were two entries for the same timestamp. The first record had the pmu, wt, and cpu as what was used, but the second entry had all the values of those as 0.

aik099 commented 9 years ago

Maybe that is how information is stored. I never looked at the database, since UI shows me all I need to know.

Vidzz commented 9 years ago

Initially there was only one record for a url visited. Now, there are two records. The second record doesn't store the metrics. (i.e. 0). Even in UI, got the metric value as 0 Eg: Last 25 Runs Timestamp Cpu Wall Time Peak Memory Usage
Aug 07 11:31:13 53e3162c5b75e 0 0 0
Aug 07 11:31:13 53e3162c5801b 635903 3249014 10308648

aik099 commented 9 years ago

All records in mine details table contain non-zero number pmu column.

preinheimer commented 9 years ago

The application now uses register shutdown function to set up the the recording of data: https://github.com/preinheimer/xhprof/blob/master/external/header.php#L134

You'll get two copies of data if you're also manually including footer.php.

aik099 commented 9 years ago

I'm including only header by the way. Then I understand why all works fine in my case.

Vidzz commented 9 years ago

How is it possible to include only the header? The footer contains the xhprof_disable to stop the profiling right? Is it possible to stop profiling without using footer.php? Also what are the changes to be made f=to achieve that?

aik099 commented 9 years ago

@Vidzz , please reffer to https://github.com/preinheimer/xhprof/issues/81#issuecomment-51459241 and http://php.net/manual/en/function.register-shutdown-function.php

Vidzz commented 9 years ago

@aik099 - I couldn't get you. You mean to say you used header.php in register_shutdown_function? Or the function wasn't called?

aik099 commented 9 years ago

@preinheimer said, that header.php now uses register_shutdown_function to call footer.php automatically. Maybe you're unaware what register_shutdown_function does, I don't know.

preinheimer commented 9 years ago

@Vidzz header.php includes footer.php automatically now, you don't need to include it yourself.

Vidzz commented 9 years ago

@preinheimer @aik099 Thanks for the help. I actually included both.