From dd47cb820c8da4c300e7217f69000ee0a0447fca Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Sun, 27 Apr 2014 09:01:58 +0000 Subject: [PATCH] added hrtime example git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@333432 c90b9560-bf6c-de11-be94-00142212c4b1 --- reference/hrtime/book.xml | 2 +- reference/hrtime/examples.xml | 62 +++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 reference/hrtime/examples.xml diff --git a/reference/hrtime/book.xml b/reference/hrtime/book.xml index b725163319..004491f21f 100644 --- a/reference/hrtime/book.xml +++ b/reference/hrtime/book.xml @@ -15,7 +15,7 @@ a custom stopwatch using low level ticks delivered by the underlaying APIs. &reference.hrtime.setup; - + &reference.hrtime.examples; &reference.hrtime.hrtime.performancecounter; &reference.hrtime.hrtime.stopwatch; &reference.hrtime.hrtime.unit; diff --git a/reference/hrtime/examples.xml b/reference/hrtime/examples.xml new file mode 100644 index 0000000000..8674cd5a32 --- /dev/null +++ b/reference/hrtime/examples.xml @@ -0,0 +1,62 @@ + + + + &reftitle.examples; +
+ Basic usage + + The example illustrates the basic StopWatch class usage + + + Measure several code blocks execution and get the total + +start(); +/* measure this code block execution */ +for ($i = 0; $i < 1024*1024; $i++); +$c->stop(); +$elapsed0 = $c->getLastElapsedTime(HRTime\Unit::NANOSECOND); + +/* measurement is not running here*/ +for ($i = 0; $i < 1024*1024; $i++); + +$c->start(); +/* measure this code block execution */ +for ($i = 0; $i < 1024*1024; $i++); +$c->stop(); +$elapsed1 = $c->getLastElapsedTime(HRTime\Unit::NANOSECOND); + +$elapsed_total = $c->getElapsedTime(HRTime\Unit::NANOSECOND); + +?> +]]> + + +
+
+ + +