Split the examples making them easier to read

Changed the name of the function which returns microtime as a float to microtime_float


git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@164733 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Aidan Lister 2004-07-30 14:50:51 +00:00
parent 35fc8e364f
commit 00ce37ce6d

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.9 $ -->
<!-- $Revision: 1.10 $ -->
<!-- splitted from ./en/functions/datetime.xml, last change in rev 1.2 -->
<refentry id="function.microtime">
<refnamediv>
@ -38,41 +38,46 @@
</note>
<para>
<example>
<title><function>microtime</function> example</title>
<title>Timing script execution with <function>microtime</function></title>
<programlisting role="php">
<![CDATA[
<?php
function getmicrotime()
/**
* Simple function to replicate PHP5 behaviour
*/
function microtime_float()
{
list($usec, $sec) = explode(" ", microtime());
return ((float)$usec + (float)$sec);
}
$time_start = getmicrotime();
for ($i=0; $i < 1000; $i++) {
// do nothing, 1000 times
}
$time_start = microtime_float();
$time_end = getmicrotime();
// Sleep for a while
usleep(100);
$time_end = microtime_float();
$time = $time_end - $time_start;
echo "Did nothing in $time seconds\n";
?>
]]>
</programlisting>
</example>
<example>
<title>Timing script execution in PHP5</title>
<programlisting role="php">
<![CDATA[
<?php
$time_start = microtime(true);
// with PHP 5 you can do the same this way:
// Sleep for a while
usleep(100);
$time_start = microtime(1);
for ($i=0; $i < 1000; $i++) {
// do nothing, 1000 times
}
$time_end = microtime(1);
$time_end = microtime(true);
$time = $time_end - $time_start;
echo "Did nothing in $time seconds\n";
?>
]]>
</programlisting>
@ -103,4 +108,4 @@ End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->
-->