Hi,

> -----Original Message-----
> From: Niklas Keller [mailto:m...@kelunik.com]
> Sent: Friday, January 13, 2017 4:46 PM
> To: Leigh <lei...@gmail.com>
> Cc: Anatol Belski <anatol....@belski.net>; Michael Wallner <m...@php.net>;
> PHP Internals <internals@lists.php.net>; Bob Weinand <bwo...@php.net>;
> Daniel Lowrey <rdlow...@php.net>
> Subject: Re: [PHP-DEV] Fwd: Monotonic Time
> 
> 2017-01-13 15:06 GMT+01:00 Leigh <lei...@gmail.com>:
> 
> > On Fri, 13 Jan 2017 at 09:35 Niklas Keller <m...@kelunik.com> wrote:
> >
> > > Hi Anatol,
> > >
> > > Do you think we should merge hrtime into core or add a simple
> > > function
> > just
> > > like microtime() to ext/standard?
> > >
> > > Regards, Niklas
> > >
> >
> > It would be great if it could be a simple function, however it is
> > going to be difficult to produce something cross-platform and
> > meaningful with a single function. (I know Anatol has written portable
> > code, I haven't looked at it but I assume it's wrapping the various structs 
> > used
> by i.e.
> > performance counters, hrtime, etc.)
> >
> > I don't think we can get away from having an object-based
> > implementation to wrap those internal structs, but I do think this is
> > a useful addition regardless of how it's presented.
> >
> 
> With timer.c it's very easy to have it as one function, in fact it's a simple 
> static
> method currently doing exactly what I think it should probably do in core as a
> function.
> 
> http://svn.php.net/viewvc/pecl/hrtime/trunk/hrtime.c?revision=341600&view=
> markup
> < Line 416.
> 
The PerformanceCounter class from the hrtime ext allows to implement any time 
measurement directly in PHP. It provides the most low level units used by the 
system, the ticks. To convert ticks into actual time, the tick frequency is 
required. The frequency can be actually hidden from the implementation, or 
could be exposed to PHP. Exposing might be useful for several reasons, fe if 
one would want to compare different systems. Anyway, these are the base bricks.

Niklas, about merging into core - not sure it needs the StopWatch class, but 
maybe. The performance counter class, at the very low level, could have more 
chance. Taking timer.c as base should be fine, too, even there is a significant 
improved potential down to the ASM level later, though very platform specific. 
In first place what would make sense to know - what exact usage would it be? 
More specific use case info is what is needed to discuss and figure out the 
required implementation.

Regards

Anatol





--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to