[erlang-questions] '--' BIF to be used with caution?

Hynek Vychodil <>
Wed Feb 11 09:58:38 CET 2009


On Wed, Feb 11, 2009 at 1:25 AM, Richard O'Keefe <> wrote:

> I asked why (--) could not be implemented in Erlang instead of C.
>
> On 10 Feb 2009, at 9:44 pm, Hynek Vychodil wrote:
>
>> It's easy, constants for serious amount |2|.
>>
>
> I am not sure how to interpret this.
> Let's face it, *as currently implemented* -- is not
> only inefficient, it can block scheduling for non-
> trivial amounts of time.  So as things stand now,
> fully informed programmers are unlikely to make very
> much use of it, so in any program where the constant
> factors are likely to make much difference, it is
> _already_ so slow that something else should be done.
> For example, I just measured some times:
>
> 681.69 msec, bag difference of unsorted lists using --
>  0.64 msec, bag difference of sorted lists using own
>             sorted list difference code in Erlang
>  24.97 msec, bag difference of unsorted lists by
>             sorting then using sorted list difference.
>
> The one relying on a C coded -- is the slowest of them.
>
> OK, so the lists were 10,000 elements long.  Make them
> 10 times smaller, and the times are
>  5.24 msec unsorted then --
>  0.08 msec presorted, use own Erlang
>  1.63 msec unsorted, use sort then own Erlang.
> Still the same conclusion: even coded in C, -- is too
> slow to use with any lists that might be nontrivial.
> So who cares about the constant factors in an operation
> that you shouldn't be using?  Every time we move something
> out of C into Erlang we simplify the trusted base.
>
>
>
Nice, and now measure this for 5 element long lists.


-- 
--Hynek (Pichi) Vychodil

Analyze your data in minutes. Share your insights instantly. Thrill your
boss.  Be a data hero!
Try Good Data now for free: www.gooddata.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20090211/10eebdb5/attachment.html>


More information about the erlang-questions mailing list