Ticket #242 (closed Feature Request: fixed)

Opened 9 months ago

Last modified 2 weeks ago

Improve Profiler library

Reported by: PugFish Assigned to: PugFish
Priority: minor Milestone: 2.2
Component: Libraries Version: SVN HEAD
Keywords: Cc:
SVN Revision (if applicable):

Description (Last modified by PugFish)

Make the profiler more modular. Instead of gathering data from the various libraries it will simply offer an API for displaying data that any library/helper etc can use. An event will run that they can attach to and setup their own table and then feed the data to the profiler to be displayed.

For example, maybe something like:
$this->profiler->add(

array(

'table' => array(

'Title' => '200px, #FF00FF, bold', // column 1
'Title Two' => '50%, #FF00FF' // column 2

),

'data' => array(

array(

'data for column 1',
'data for column 2'

), // row 1
array(

'data for column 1',
'data for column 2'

), // row 2

)

)

);

Attachments

profiler.patch (0.7 kB) - added by charlie on 06/09/08 11:34:57.
An extremely minor, but handy patch for totaling up rows for database queries in addition to query execution time.

Change History

11/25/07 22:21:16 changed by PugFish

  • description changed.

11/26/07 12:41:09 changed by zombor

We should also add support for adding up times if a profiler section has multiple values, like the database section. For example, it should add up the total time to execute all the queries.

11/26/07 14:48:12 changed by Shadowhand

  • version changed from 2.1 to SVN HEAD.

12/10/07 01:29:28 changed by Shadowhand

I think using a syntax more similar to Forge, where each datatype has it's own class/object would make more sense.

Also, check out Flot!

01/15/08 09:58:41 changed by gregmac

  • type changed from Task to Feature Request.
  • component changed from Core to Libraries.

01/17/08 10:58:20 changed by PugFish

  • milestone changed from 2.1 to 2.2.

05/22/08 19:16:42 changed by Nodren

just thought i should interject something, i saw the new profiler library on svn, and i think its great. however in case people want to extend the profiler library to display extra profiling information... you offered the profiler.run inside the render function, which is great, except the built in functions that display different profiling information dont use the event, so if someone were to extend the library, they would be forced to have the new information rendered first, this while it works, could be done better, as events allow you to inject your callback anywhere in the list.. i just think that could be a better solution so i propose changing these lines:

Event::run('profiler.run');

$this->benchmarks();
$this->database();
$this->session();
$this->post();
$this->cookies();


to these lines

//add these in the __construct statement
Event::add('profiler.run',array($this,'benchmarks');
Event::add('profiler.run',array($this,'database');
Event::add('profiler.run',array($this,'session');
Event::add('profiler.run',array($this,'post');
Event::add('profiler.run',array($this,'cookies');

//replace the lines existing with just this line remaning
Event::run('profiler.run');

05/22/08 19:53:30 changed by PugFish

Good idea. I was originally going to have each profile added from their respective library but this would be a little slower as they'd get added even when the profiler wasn't loaded, so I put them into the Profiler library itself and hardlinked them til I had decided what to do with them.

Changes made in r2687

05/23/08 01:15:47 changed by charlie

Maybe I'm missing something here, but it seems like I could add things to the profiler without extending it. This might be nice if libraries want to provide their own profiling information, while at the same time allowing other libraries to insert profiling information. To do this, I added an event binding in my library: Event::add('profiler.run', aray($this, 'profile'));

then inserted a function called 'profile' into my library.

From here, I was unable to get the profiler table to add my profiling data. To support this, I added a private static $running_instance to the profiler class. Additionally, a public static instance() method that returns this. The variable is set to $this just before invoking the profiler.run event, so any library can get a reference to the currently executing profiler easily.

If there was already a way to do this, any information would be greatly appreciated. Otherwise, I think it may be worth supporting the addition of profiling information without extending the Profiler class or overwriting other modules' or libraries' profiling code.

05/23/08 01:20:21 changed by charlie

I should have thought this through before posting. An easier way to do this is to change:

Event::run('profiler.run');

to

Event::run('profiler.run', $this);

Then Event::$data will always reference the currently executing profiler.

05/23/08 12:09:35 changed by PugFish

Oops, it was already meant to work like that but I overlooked it, thanks for pointing it out.

Fixed in r2688

Also please note that some of the Profiler_Table stuff is probably going to change, i'm not entirely happy with how it works and there's a style problem in IE6 where the table title has no colour.

05/23/08 12:42:10 changed by charlie

That checkin does it for me. I'll take a look at the IE6 coloring bug here if you'd like. I'm at work, and we're all set up to do cross-browser testing. There's a real CSS pro here who might have some ideas if I can't get it.

05/23/08 12:56:38 changed by PugFish

I know what's causing it, but due to the way the row styles are applied with the current Profiler_Table there's no way around it. I'm going to look at doing it a better way when I get some spare time.

06/09/08 11:34:57 changed by charlie

  • attachment profiler.patch added.

An extremely minor, but handy patch for totaling up rows for database queries in addition to query execution time.

08/06/08 10:32:38 changed by Shadowhand

  • status changed from new to closed.
  • resolution set to fixed.