From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id QAA04855; Tue, 4 Mar 2003 16:06:09 +0100 (MET) Received: (from xleroy@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id QAA04518 for caml-list@pauillac.inria.fr; Tue, 4 Mar 2003 16:06:06 +0100 (MET) Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id BAA16764 for ; Tue, 4 Mar 2003 01:24:25 +0100 (MET) Received: from nef.ens.fr (nef.ens.fr [129.199.96.32]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id h240OOT08687 for ; Tue, 4 Mar 2003 01:24:24 +0100 (MET) Received: from clipper.ens.fr (clipper-gw.ens.fr [129.199.1.22]) by nef.ens.fr (8.12.8/1.01.28121999) with ESMTP id h240OOqZ028033 ; Tue, 4 Mar 2003 01:24:24 +0100 (CET) Received: from localhost (frisch@localhost) by clipper.ens.fr (8.12.3/jb-1.1) id h240ON5L011315 ; Tue, 4 Mar 2003 01:24:23 +0100 (MET) X-Authentication-Warning: clipper.ens.fr: frisch owned process doing -bs Date: Tue, 4 Mar 2003 01:24:23 +0100 (MET) From: Alain.Frisch@ens.fr X-X-Sender: frisch@clipper.ens.fr Reply-To: Alain.Frisch@ens.fr To: Issac Trotts cc: OCaml List Subject: Re: [oliver: Re: [Caml-list] Strings as arrays or lists...] In-Reply-To: <3E63F13E.4090303@ucdavis.edu> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by amavisd-milter (http://amavis.org/) X-Spam: no; 0.00; alain:01 frisch:01 oliver:01 caml-list:01 issac:01 trotts:01 char:01 tradeoff:01 slower:01 arrays:01 ocaml:01 toplevel:01 benchmark:02 string:03 wrote:03 X-Spam: no; 0.00; alain:01 frisch:01 oliver:01 caml-list:01 issac:01 trotts:01 char:01 tradeoff:01 slower:01 arrays:01 ocaml:01 toplevel:01 benchmark:02 string:03 wrote:03 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Mon, 3 Mar 2003, Issac Trotts wrote: > Char arrays take up four times as much space as strings, but there is a > tradeoff > of space versus time. The statement > > let a = Array.make 2000000 ' ';; > > takes no noticable time, but > > let s = String.make 2000000 ' ';; > > takes about 7 seconds to run on my computer. Oh really ? I'm interested in your benchmark methodology. Hint: it may be the case that the pretty-printing of s in the toplevel is slower that the pretty-printing of a, but this is not relevant, is it ? As for me, I get: glouglou ~/tmp $ cat a.ml let a = Array.make 2000000 ' ';; glouglou ~/tmp $ time ocaml a.ml ocaml a.ml 0,16s user 0,01s system 101% cpu 0,167 total glouglou ~/tmp $ cat s.ml let s = String.make 2000000 ' ';; glouglou ~/tmp $ time ocaml s.ml ocaml s.ml 0,04s user 0,02s system 102% cpu 0,058 total glouglou ~/tmp $ cat x.ml glouglou ~/tmp $ time ocaml x.ml ocaml x.ml 0,03s user 0,01s system 108% cpu 0,037 total (x.ml is an empty file, to evaluate ocaml toplevel startup time) Which seems to indicate that String.make is unsurpisingly a lot faster than Array.make. -- Alain ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners