[erlang-questions] hrtime/0, Was: now/0 resolution
Wed Sep 12 10:23:18 CEST 2007
There is support in Hipe for accessing performance counters in the CPU.
These has been used to great advantage while benchmarking and finding
bottlenecks in HiPE.
Take a look at
Perhaps it is time to make them official...
On 12 sep 2007, at 09.42, Raimo Niskanen wrote:
> So, to conclude this thread, there is no much better way today.
> Call trace may in some cases be more convenient but not
> much more efficient and has no better precision.
> New question:
> Serge apparently want a new BIF e.g hrtime/0 that would return
> the best high resolution time the implementation knows on the
> running OS. The precision would be OS dependant, but the best
> known to the emulator, and it would be the fastest way to get it.
> This BIF could also be suitable for getting high resolution
> CPU time as well as wallclock time.
> How much interest for such a BIF is there from the community?
> This would perhaps better be asked for in an EEP, but
> this is a first poll.
> Came to think about it. The current suggestion for FFI
> (Forein Function Interface) could be used to call the OS
> high resolution time functions, but then you would have
> to know the right call on every OS, and I do not know
> how efficient that call interface would be.
> On Fri, Sep 07, 2007 at 07:23:34AM -0500, Serge Aleynikov wrote:
>> Since according to documentation consecutive executions of now/0 will
>> return different values (with microsecond precision) I have two
>> 1. Does it mean that inserting now/0 calls in code will slow down
>> execution to 1mks per execution? If not, then performance of
>> call measured using now/0 time stamping would be inaccurate.
>> 2. Is it possible to measure execution time more accurately (with
>> nanosecond precision) using current Erlang distribution? (*)
>> (*) Since VM uses gettimeofday() to bump timer, it's limited by
>> getimeofday's precision. Additionally each invocation of
>> takes about 15mks (OS dependent). I believe that there's no code to
>> take advantage of a high resolution timer. Such a timer can give
>> nanosecond precision, and presently the only way it can be
>> is in a linked-in driver. The only problem that calling functions
>> inside the driver with erlang:port_call/3 incurs some cost that
>> would be
>> better to avoid if a bif (such as hrnow/0) was available.
>> erlang-questions mailing list
> / Raimo Niskanen, Erlang/OTP, Ericsson AB
> erlang-questions mailing list
More information about the erlang-questions