Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion list vs binary performarnce, destructuring and consing

Received: by 10.204.129.9 with SMTP id m9mr2145290bks.1.1350993647969;
        Tue, 23 Oct 2012 05:00:47 -0700 (PDT)
X-BeenThere: erlang-programming@googlegroups.com
Received: by 10.204.151.24 with SMTP id a24ls260611bkw.1.gmail; Tue, 23 Oct
 2012 05:00:47 -0700 (PDT)
Received: by 10.205.123.145 with SMTP id gk17mr2146767bkc.2.1350993647530;
        Tue, 23 Oct 2012 05:00:47 -0700 (PDT)
Received: by 10.205.123.145 with SMTP id gk17mr2146766bkc.2.1350993647511;
        Tue, 23 Oct 2012 05:00:47 -0700 (PDT)
Return-Path: <erlang-questions-boun...@erlang.org>
Received: from hades.cslab.ericsson.net (hades.cslab.ericsson.net. [192.121.151.104])
        by gmr-mx.google.com with ESMTP id v13si1308773bkw.0.2012.10.23.05.00.47;
        Tue, 23 Oct 2012 05:00:47 -0700 (PDT)
Received-SPF: pass (google.com: domain of erlang-questions-boun...@erlang.org designates 192.121.151.104 as permitted sender) client-ip=192.121.151.104;
Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of erlang-questions-boun...@erlang.org designates 192.121.151.104 as permitted sender) smtp.mail=erlang-questions-boun...@erlang.org
Received: from hades.cslab.ericsson.net (hades [192.121.151.104])
	by hades.cslab.ericsson.net (Postfix) with ESMTP id B34505C47A;
	Tue, 23 Oct 2012 14:00:39 +0200 (CEST)
X-Original-To: erlang-questi...@erlang.org
Delivered-To: erlang-questi...@erlang.org
Received: from zimbra.erlangsystems.com (zimbra.erlangsystems.com
 [93.93.131.195])
 by hades.cslab.ericsson.net (Postfix) with ESMTP id 345405C022
 for <erlang-questi...@erlang.org>; Tue, 23 Oct 2012 14:00:38 +0200 (CEST)
Received: from localhost (localhost.localdomain [127.0.0.1])
 by zimbra.erlangsystems.com (Postfix) with ESMTP id DCA99EA002;
 Tue, 23 Oct 2012 13:00:35 +0100 (BST)
X-Virus-Scanned: amavisd-new at zimbra.erlangsystems.com
Received: from zimbra.erlangsystems.com ([127.0.0.1])
 by localhost (zimbra.erlangsystems.com [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id N+ElKQTJG84L; Tue, 23 Oct 2012 13:00:34 +0100 (BST)
Received: from [10.0.10.167] (unknown [195.184.103.10])
 by zimbra.erlangsystems.com (Postfix) with ESMTPSA id BB214EA001;
 Tue, 23 Oct 2012 13:00:34 +0100 (BST)
Mime-Version: 1.0 (Mac OS X Mail 6.2 \(1499\))
From: Jesper Louis Andersen <jesper.louis.ander...@erlang-solutions.com>
In-Reply-To: <CAFVMu-qFJ8zWW1wbTSJOaLGY_4RfB77GjVzMCRzKL+w61=g...@mail.gmail.com>
Date: Tue, 23 Oct 2012 14:00:34 +0200
Message-Id: <845CE886-A241-49EB-A3BC-AACA9EFC5...@erlang-solutions.com>
References: <CA+dr1pvr4Efu-YzyvRs0vEW1M1FTOVZ2BK4vvCfqSEJD8X_...@mail.gmail.com>
 <50865049.5040...@gmail.com>
 <CAFVMu-pFWHLac+UdYCTgmuAox+coOwbhYBsbAZe-9-22SN+...@mail.gmail.com>
 <50865CB5.8070...@ninenines.eu>
 <CAFVMu-qFJ8zWW1wbTSJOaLGY_4RfB77GjVzMCRzKL+w61=g...@mail.gmail.com>
To: =?windows-1252?Q?Motiejus_Jak=9Atys?= <desired....@gmail.com>
X-Mailer: Apple Mail (2.1499)
Cc: erlang-questi...@erlang.org
Subject: Re: [erlang-questions] list vs binary performarnce,
	destructuring and consing
X-BeenThere: erlang-questi...@erlang.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: General Erlang/OTP discussions <erlang-questions.erlang.org>
List-Unsubscribe: <http://erlang.org/mailman/options/erlang-questions>,
 <mailto:erlang-questions-requ...@erlang.org?subject=unsubscribe>
List-Archive: <http://erlang.org/pipermail/erlang-questions>
List-Post: <mailto:erlang-questi...@erlang.org>
List-Help: <mailto:erlang-questions-requ...@erlang.org?subject=help>
List-Subscribe: <http://erlang.org/mailman/listinfo/erlang-questions>,
 <mailto:erlang-questions-requ...@erlang.org?subject=subscribe>
Content-Type: text/plain; charset="windows-1252"
Content-Transfer-Encoding: quoted-printable
Errors-To: erlang-questions-boun...@erlang.org
Sender: erlang-questions-boun...@erlang.org


On Oct 23, 2012, at 11:16 AM, Motiejus Jak=9Atys <desired....@gmail.com> wr=
ote:
> =

> FYI, with "native" and some more tricks:
> BIN: Min:  124959.0, Max:  152380.0, Mean:   80449.2, stdev:  53616.5
> STR: Min:   40768.0, Max:  340067.0, Mean:  137522.3, stdev:   7299.9
> =


There is no reason to believe binaries to be faster than lists for this ben=
chmark. The list construction can take its cells from the process heap and =
since it is garbage collected, doing so is an (amortized) O(1) pointer move=
. The reverse takes O(N). So we are looking at N*O(1) + O(N) =3D O(N). The =
binary construction has to reallocate the binary once in a while which impo=
ses a copy on the binary to make it larger. In the worst case, and when it =
is badly implemented, this is an O(N^2) operation. If it is better implemen=
ted, we can shave it down to O(N lg N) or thereabout, depending on the slac=
k amount we want to allocate. But it does not seem as cheap as the other so=
lution, barring constants.

If you want to do better at the stats, report the median or better, the 25t=
h, 50th, 75th, 90th, 95th and 99th percentile. I don't think the mean can b=
e used for anything since we don't know if the thing we are looking at happ=
ens to be a normal distribution. Or you could plot the kernel density. Just=
 taking

tiefling=3D; dc -e '340067 40768 + 2 / p'
190417

does suggest that something is fishy since this is way away from the mean.

Jesper Louis Andersen
  Erlang Solutions Ltd., Copenhagen

_______________________________________________
erlang-questions mailing list
erlang-questi...@erlang.org
http://erlang.org/mailman/listinfo/erlang-questions