note 69242 added to control-structures.declare
| From: | rosen_ivanov at abv dot bg | Date: | Mon, 28 Aug 2006 13:06:33 +0000 |
| Subject: | note 69242 added to control-structures.declare | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-116430@lists.php.net to get a copy of this message | ||
As Chris already noted, ticks doesn't make your script multi-threaded, but they are still
great. I use them mainly for profiling - for example, placing the following at the very beginning of
the script allows you to monitor its memory usage:
<?php
function profiler($return=false) {
static $m=0;
if ($return) return "$m bytes";
if (($mem=memory_get_usage())>$m) $m = $mem;
}
register_tick_function('profiler');
declare(ticks=1);
/*
Your code here
*/
echo profiler(true);
?>
This approach is more accurate than calling memory_get_usage only in the end of the script. It has
some performance overhead though :)
----
Server IP: 195.149.248.161
Probable Submitter: 195.234.238.202
----
X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER
autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/control-structures.declare.php
Edit -- https://master.php.net/note/edit/69242
Del: integrated -- https://master.php.net/note/delete/69242/integrated
Del: useless -- https://master.php.net/note/delete/69242/useless
Del: bad code -- https://master.php.net/note/delete/69242/bad+code
Del: spam -- https://master.php.net/note/delete/69242/spam
Del: non-english -- https://master.php.net/note/delete/69242/non-english
Del: in docs -- https://master.php.net/note/delete/69242/in+docs
Del: other reasons-- https://master.php.net/note/delete/69242
Reject -- https://master.php.net/note/reject/69242
Search -- https://master.php.net/manage/user-notes.php