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 AAA29769; Thu, 15 May 2003 00:41:33 +0200 (MET DST) 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 AAA29295 for ; Thu, 15 May 2003 00:41:32 +0200 (MET DST) Received: from swordfish ([216.241.35.41]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id h4EMfUT24956 for ; Thu, 15 May 2003 00:41:31 +0200 (MET DST) Received: from matt by swordfish with local (Exim 3.35 #1 (Debian)) id 19G4wF-0007cU-00 for ; Wed, 14 May 2003 16:41:31 -0600 Date: Wed, 14 May 2003 16:41:31 -0600 From: Matt Gushee To: caml-list@pauillac.inria.fr Subject: Re: [Caml-list] Performance problem Message-ID: <20030514224130.GC27927@swordfish> Reply-To: Matt Gushee Mail-Followup-To: caml-list@pauillac.inria.fr References: <20030514210332.GA27927@swordfish> <16066.49355.349534.889868@karryall.dnsalias.org> <20030514210332.GA27927@swordfish> <55DB7CE4-8659-11D7-9845-000393863F70@exomi.com> <20030514223956.GB27927@swordfish> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20030514223956.GB27927@swordfish> User-Agent: Mutt/1.3.27i X-Spam: no; 0.00; gushee:01 mgushee:01 havenrock:01 caml-list:01 buffering:01 terrible:01 slower:01 non-trivial:01 andrieu:01 3.06:01 0.16:01 englewood:01 manure:01 ignores:01 --lao:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Thu, May 15, 2003 at 01:13:48AM +0300, Ville-Pertti Keinonen wrote: > >that occur to me are an output buffering problem or some delay in > >interacting with the X display, but I'm not sure how to solve either of > >those. And maybe it's something else entirely. Can anyone explain my > >terrible results? > > My guess (without profiling) is that most of the time is being spent > doing regular expression matching. > > Regular expressions can be much slower than you might expect for > non-trivial cases. The expression in your program looks particularly > nasty, since there are a lot of ambiguous cases (whether '-' should > match '.*' or '-' depends on everything that follows). > > You might want to try using Str.split instead. Good point. I don't know why I didn't think of that in the first place. On Thu, May 15, 2003 at 12:18:51AM +0200, Olivier Andrieu wrote: > > Hi, I don't really know where your performance problem come from, but : > > 1) you regexp string is not properly escaped, all the "\(" and "\)" > should be "\\(" and "\\)". Okay, I've run into that with other languages. But I didn't know you had to do that in OCaml. Is that documented anywhere? > (I guess you're not using ocaml 3.06 > because it prints a lot of warnings concerning these). Oh, I've seen those warnings more than once, and was thinking about asking on the list, but it didn't seem urgent. By the way, why doesn't the compiler just reject regexes with single backslashes? What is the point of issuing warnings and then accepting the incorrect syntax? > 2) there are no problems using bytecode : > 0.3s using bytecode > 23s using native How strange. I actually didn't try compiling to bytecode. I had tried using the function in the interactive toplevel, and finding it very slow, went straight to native code in the hope that it would perform reasonably well. Any idea why bytecode would be faster? > 3) you should use "[^-]*" instead of ".*" : this makes life easier for > the regexp matching and thus runs faster. > 0.16s bytecode > 0.03s native Ah, another good point. I think I'll go with Str.split, but I'll keep this in mind for future reference. Thank you both for the suggestions. -- Matt Gushee When a nation follows the Way, Englewood, Colorado, USA Horses bear manure through mgushee@havenrock.com its fields; http://www.havenrock.com/ When a nation ignores the Way, Horses bear soldiers through its streets. --Lao Tzu (Peter Merel, trans.) ------------------- 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