RE: [PHP] how the "ticks" works?
| From: | Martin Towell | Date: | Wed, 20 Feb 2002 22:19:47 +0000 |
| Subject: | RE: [PHP] how the "ticks" works? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-85619@lists.php.net to get a copy of this message | ||
As the manual says - it executes the "tick" function every 'n' low-level
statement - but what's counted as a low-level statement, I don't know...
It appears that, in the example, the low-level statements are the "for" and
the "echo"
If anyone can shed light on this subject, I'd be interested too
Martin
-----Original Message-----
From: bob [mailto:lly200146@sohu.com]
Sent: Thursday, February 21, 2002 12:39 AM
To: php-general@lists.php.net
Subject: [PHP] how the "ticks" works?
I don't understand how the 'ticks' works: please help me.
<pre>
<?php
// A function that records the time when it is called
function profile ($dump = FALSE)
{
static $profile;
// Return the times stored in profile, then erase it
if ($dump) {
$temp = $profile;
unset ($profile);
return ($temp);
}
$profile[] = microtime ();
}
// Set up a tick handler
register_tick_function("profile");
// Initialize the function before the declare block
profile ();
// Run a block of code, throw a tick every 2nd statement
declare (ticks=2) {
for ($x = 1; $x < 50; ++$x) {
echo similar_text (md5($x), md5($x*$x)), "<br>";
}
}
// Display the data stored in the profiler
print_r (profile (TRUE));
?>
</pre>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php