Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 5 Apr 2005 23:20:43 -0700
From:      Brooks Davis <brooks@one-eyed-alien.net>
To:        Matthew Dillon <dillon@apollo.backplane.com>
Cc:        Jeremie Le Hen <jeremie@le-hen.org>
Subject:   Re: strcspn(3) complexity improvement
Message-ID:  <20050406062043.GB22691@odin.ac.hmc.edu>
In-Reply-To: <200504060346.j363ko4b088610@apollo.backplane.com>
References:  <20050330083435.GI75546@obiwan.tataz.chchile.org> <20050330110613.GB71384@cirb503493.alcatel.com.au> <20050330183145.GB24465@odin.ac.hmc.edu> <200504060346.j363ko4b088610@apollo.backplane.com>

next in thread | previous in thread | raw e-mail | index | archive | help

--p4qYPpj5QlsIQJ0K
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Tue, Apr 05, 2005 at 08:46:50PM -0700, Matthew Dillon wrote:
> :The real question I have is, how long does the string need to be before
> :this is a win and how much does it hurt for typical string lengths?
> :I've written code with strcspn that needed to perform well, but it was
> :parsing 80-column punch card derived formats.
>=20
>      I think the answer is to not use strcspn() in cases where it *really*
>      matters.

Certainly.  strcspn() wasn't worth optimizing out after I replaced the
hand coded crap that used getc to parse files up to 100MB is size and
did a realloc for each character!  That got me a 50% speedup in overall
execution time and the function dropped from #1 to <#50 in the
profiling numbers.  At that point FPU intensive code was at the top
where it belonged.

My main point was to avoid a purely theoretical "optimization".

-- Brooks

--=20
Any statement of the form "X is the one, true Y" is FALSE.
PGP fingerprint 655D 519C 26A7 82E7 2529  9BF0 5D8E 8BE9 F238 1AD4

--p4qYPpj5QlsIQJ0K
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)

iD8DBQFCU3+yXY6L6fI4GtQRAo3cAKCjGIbjiZbYPuBrUDMBmlq8s9UbqgCaAj8u
PMXZq4cqToA2dCnZ7RUy2E0=
=fV/5
-----END PGP SIGNATURE-----

--p4qYPpj5QlsIQJ0K--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20050406062043.GB22691>