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 CAA17544; Tue, 4 Mar 2003 02:00:07 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id CAA17708 for ; Tue, 4 Mar 2003 02:00:05 +0100 (MET) Received: from marble.he.net (marble.he.net [216.218.230.2]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id h24104H27492 for ; Tue, 4 Mar 2003 02:00:04 +0100 (MET) Received: from ucdavis.edu ([208.227.214.58] (may be forged)) by marble.he.net (8.8.6/8.8.2) with ESMTP id RAA20726 for ; Mon, 3 Mar 2003 17:00:01 -0800 Message-ID: <3E63FC18.1030108@ucdavis.edu> Date: Mon, 03 Mar 2003 17:06:32 -0800 From: Issac Trotts User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.1) Gecko/20020913 Debian/1.1-1 MIME-Version: 1.0 To: OCaml List Subject: Re: [oliver: Re: [Caml-list] Strings as arrays or lists...] References: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Spam: no; 0.00; issac:01 trotts:01 ijtrotts:01 oliver:01 caml-list:01 alain:01 frisch:01 char:01 tradeoff:01 slower:01 arrays:01 ocaml:01 toplevel:01 catching:02 benchmark:02 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Alain.Frisch@ens.fr wrote: >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 > > You're right. Thanks for catching my error. Issac ------------------- 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