Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
substring match like "strstr"
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Eijiro Sumii <sumii@v...>
Subject: Re: substring match like "strstr"
Julian Assange <> wrote:
> All of these more sophisticated methods are only going to be a win
> when you are searching for larger strings. strstr is brutally simple,
> has little setup/cleanup time, and hence is hard to beat for short
> strings.

That is completely correct, and the substrings in my application are
indeed short (3 characters), but: wrote:
| Since my program calls the function more than 3000 times for _each_
| pattern, I did partial application, of course.  Even so, kmp in OCaml
| still performed much worse than strstr in libc (both Sun's and GNU's),
| at least in this program.

I expected that 3000 strings for 1 substring, each of which are about
20 characters long as I mentioned before, are enough for paying the
"setup/cleanup" overhead.  (On the other hand, strstr in libc doesn't
benefit from the partial application, of course.)