caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Jean-Christophe Filliatre <Jean-Christophe.Filliatre@lri.fr>
To: Christophe TROESTLER <debian00@tiscalinet.be>
Subject: Re: [Caml-list] The invert Benchmark
Date: Thu, 18 Apr 2002 11:11:06 +0200 (MEST)	[thread overview]
Message-ID: <15550.36266.927283.406730@pc803.lri.fr> (raw)
In-Reply-To: <20020417.202615.87280210.debian00@tiscalinet.be>


Christophe TROESTLER writes:
 > Dear Caml riders,
 > 
 > I found by chance the "The invert Benchmark"
 > (http://www.lib.uchicago.edu/keith/crisis/benchmarks/invert/).  As you
 > will notice the Caml code (even compiled) performs poorly.  I guess
 > part of the problem is due to using Map when Hashtbl is more suited.
 > So I tried to rewrite the code using Hashtbl (attached to this mail).
 > What I got some trouble to figure out is how to get a list of the keys
 > where each of the keys appears only once.  I eventually went the easy
 > way.  Anybody got better ideas to improve efficiency?  Could a "keys"
 > function be an interesting addition to Hashtbl???

As  suggested  by  Xavier,  String.concat  substituted  for  the  join
function really helps.

A simple profiling  with gprof also showed that both  in your code and
in  the  original one,  a  lot of  time  was  spent building  regexps!
Factorizing  out Str.{regexp,regexp_string} "\t"  (i.e. doing  it only
once in a global variable) really improves performances.

Anyway, using Str.split to cut a  string in two is a bit costly; doing
it directly as Markus did also improves performances.

-- 
Jean-Christophe Filliâtre (http://www.lri.fr/~filliatr)

-------------------
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


      parent reply	other threads:[~2002-04-18 10:56 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-04-17 18:26 Christophe TROESTLER
2002-04-17 20:04 ` Xavier Leroy
2002-04-17 20:28   ` Nadji.Gauthier
2002-04-18 19:07   ` [Caml-list] " Christophe TROESTLER
2002-04-18 19:21     ` Mattias Waldau
2002-04-17 20:13 ` [Caml-list] " Remi VANICAT
2002-04-17 20:30 ` Markus Mottl
2002-04-17 21:19   ` Mattias Waldau
2002-04-18  9:11 ` Jean-Christophe Filliatre [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=15550.36266.927283.406730@pc803.lri.fr \
    --to=jean-christophe.filliatre@lri.fr \
    --cc=debian00@tiscalinet.be \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).