JProfiler

From Joomla! Documentation
(Difference between revisions)
Jump to: navigation, search
m (Added availability section.)
m (bad link repair)
 
(4 intermediate revisions by one user not shown)
Line 1: Line 1:
{{review}}
+
This class is available in the following Joomla versions:-
 
+
<splist showpath=notparent />
'''JProfiler''' is a class for performance analysis of your code. It allows to trace:
+
<noinclude>[[Category:Platform JClasses]][[Category:JProfiler]]</noinclude>
* execution time of a particular code part;
+
* memory amount used by your script at a specific program point.
+
 
+
A JProfiler object allows you to make performance marks at specified parts of your script. It stores this marks in a buffer and provides operations for accessing it.
+
Mark is a string with the following structure:
+
 
+
<pre>
+
Application Start: 0.000 seconds, 0.10 MB
+
\_________/ \___/  \___________/  \_____/
+
    |        |          |          |
+
  prefix  label      time      memory
+
</pre>
+
 
+
Where:
+
*prefix -- serves as an identifier for distinct JProfiler objects (see below);
+
*label -- the name of a performance mark;
+
*time -- time from a JProfiler object creation to a mark setting;
+
*memory -- memory allocated to your script in a moment when a performance mark is setting.
+
 
+
The JProfiler class provides getInstance method that we can call statically. It serves for organisation of a global access point for distinct JProfiler objects. It stores an array of created objects and gives access to them on the grounds of a prefix which can be provided as an argument. Also, if an object with demanded prefix is absent, then getInstance method will create it.
+
 
+
===Availability===
+
{{JVer|1.5}} {{JVer|1.6}}
+
 
+
===Defined in===
+
/joomla/error/profiler.php
+
 
+
===Methods===
+
[http://api.joomla.org/Joomla-Framework/Error/JProfiler.html#sec-methods JProfiler methods on api.joomla.org]
+
 
+
===Importing===
+
<source lang="php">jimport( 'joomla.error.profiler' );</source>
+
 
+
===Example===
+
<source lang="php">
+
$p = JProfiler::getInstance('Application');
+
 
+
$p->mark('Start');
+
$a = str_repeat("hello world!\n", 100000);
+
$p->mark('Middle');
+
unset($a);
+
$p->mark('Stop');
+
 
+
print_r($p->getBuffer());
+
</source>
+
 
+
would output
+
 
+
<pre>
+
Array
+
(
+
    [0] => Application Start: 0.000 seconds, 0.10 MB
+
    [1] => Application Middle: 0.005 seconds, 1.34 MB
+
    [2] => Application Stop: 0.005 seconds, 0.10 MB
+
)
+
</pre>
+
 
+
===See also===
+
* [http://api.joomla.org/Joomla-Framework/Error/JProfiler.html JProfiler on api.joomla.org]
+
<noinclude>[[Category:Development]][[Category:Framework]][[Category:JProfiler]]</noinclude>
+

Latest revision as of 14:00, 29 August 2012

This class is available in the following Joomla versions:-

Page "JProfiler" has no subpages to list.
Personal tools
Namespaces

Variants
Actions
Navigation
Joomla! Sites
Toolbox