Re: Extension proposal: hrtime

From: Date: Mon, 07 Apr 2014 06:49:22 +0000
Subject: Re: Extension proposal: hrtime
References: 1 2  Groups: php.pecl.dev 
Request: Send a blank email to pecl-dev+get-11705@lists.php.net to get a copy of this message
On Mon, April 7, 2014 00:57, Chung Leong wrote: > Doesn't the win32 implementation of gettimeofday() already use the > performance timer? > > > On Sun, Apr 6, 2014 at 3:52 PM, Anatol Belski <anatol.php@belski.net> > wrote: > > >> Hi, >> >> >> I would like to propose the extension implementing a high resolution >> StopWatch class. It also makes possible to implement a custom stopwatch >> using the almost low level ticks delivered by the underlaying APIs. The >> extension does NOT implement high resolution timestamps synchronizable > to >> an external source (well, maybe yet). >> >> One reason for implementing it is the absense of the nanosecond time in >> PHP. The extension is merely focused on user space timers. >> >> >> Another reason is that Windows machines not using win8 are vulnerable >> no some unaccurate time APIs. This windows implementation uses >> performance counters to achieve some better timing results which can be >> considered stable within short time frames. Coupled with the fact that >> no synchronization to an external source is needed, that might be useful >> > for >> windows users. >> >> The extension would be released under the BSD license, the code is >> available here http://belski.net/phpz/hrtime-0.4.3.tar.gz >> >> The uses of this extension are execution time measurements of code >> > blocks >> as well as any other StopWatch use cases. The future scope were for >> example implememnting high resolution wait, however this needs some >> more variables to do it portable and right. >> >> Here's a user code example >> >> >> $c = new HRTime\StopWatch; >> >> >> $c->start(); >> /* do some interesting stuff*/ >> $c->stop(); >> $elapsed0 = $c->getLastElapsedTime(HRTime\Unit::NANOSECOND); >> >> >> /* do something else */ >> >> >> $c->start(); >> /* do some interesting stuff again */ >> $c->stop(); >> $elapsed1 = $c->getLastElapsedTime(HRTime\Unit::NANOSECOND); >> >> >> $elapsed_total = $c->getElapsedTime(HRTime\Unit::NANOSECOND); >> >> >> Regards >> >> >> Anatol >> >> >> -- >> PECL development discussion Mailing List (http://pecl.php.net/) >> To unsubscribe, visit: http://www.php.net/unsub.php >> >> >> > No, it's causing instability on different hardware. Please check bug #64633. Regards Anatol

« previous php.pecl.dev (#11705) next »