aidan Fri Jul 30 10:50:51 2004 EDT
Modified files:
/phpdoc/en/reference/datetime/functions microtime.xml
Log:
Split the examples making them easier to read
Changed the name of the function which returns microtime as a float to
microtime_float
http://cvs.php.net/diff.php/phpdoc/en/reference/datetime/functions/microtime.xml?r1=1.9&r2=1.10&ty=u
Index: phpdoc/en/reference/datetime/functions/microtime.xml
diff -u phpdoc/en/reference/datetime/functions/microtime.xml:1.9
phpdoc/en/reference/datetime/functions/microtime.xml:1.10
--- phpdoc/en/reference/datetime/functions/microtime.xml:1.9 Sat Jan 17 09:42:13
2004
+++ phpdoc/en/reference/datetime/functions/microtime.xml Fri Jul 30 10:50:51
2004
@@ -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();
+
+// Sleep for a while
+usleep(100);
-$time_end = getmicrotime();
+$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:
-
-$time_start = microtime(1);
-
-for ($i=0; $i < 1000; $i++) {
- // do nothing, 1000 times
-}
+// Sleep for a while
+usleep(100);
-$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 @@
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
--->
+-->
\ No newline at end of file