home *** CD-ROM | disk | FTP | other *** search
- From: meissner@osf.org (Michael Meissner)
- Newsgroups: alt.sources
- Subject: Re: Fast strcmp() wanted.
- Message-ID: <MEISSNER.90Oct4105717@osf.osf.org>
- Date: 4 Oct 90 14:57:17 GMT
-
- In article <6757@uwm.edu> markh@csd4.csd.uwm.edu (Mark William
- Hopkins) writes:
-
- | Path: paperboy!snorkelwacker!bionet!uwm.edu!csd4.csd.uwm.edu!markh
- | From: markh@csd4.csd.uwm.edu (Mark William Hopkins)
- | Newsgroups: alt.sources
- | Date: 4 Oct 90 06:01:08 GMT
- | References: <12145@crdgw1.crd.ge.com>
- | Sender: news@uwm.edu
- | Reply-To: markh@csd4.csd.uwm.edu (Mark William Hopkins)
- | Organization: University of Wisconsin-Milwaukee
- | Lines: 13
- |
- | In article <12145@crdgw1.crd.ge.com> larocque@jupiter.crd.ge.com (David M. LaRocque) writes:
- | >After I profiled my C program I discovered that the function
- | >strcmp() takes one third of my program's CPU time. I was hoping
- | >someone may have written their own version of strcmp() that
- | >outperforms the library's function.
- |
- | Look at some references on the architecture of the machine your system is
- | running on. It will most likely have hardware-implemented string instructions
- | that you can use.
- |
- | On our machine, the strcmp library routine is really nothing more than a single
- | assembly-language instruction with a couple register-initializations. It will
- | almost certainly run far faster than any equivalent high-level source.
-
- While it is not probably true in this case, some machine instructions
- which do strcmp are actually slower than exceedingly tight asm code
- that a real programmer can produce. It depends on many factors,
- including how much of the chip area supports the string instructions
- or whether they are microcoded. For example, the original microvax
- did not have some of the string instructions in the hardware, and
- trapped to the OS for emulation. Another example is on one other
- specific machine within an architecture family was found to do string
- moves slower than the naive load byte/store byte sequence!
-
- --
- Michael Meissner email: meissner@osf.org phone: 617-621-8861
- Open Software Foundation, 11 Cambridge Center, Cambridge, MA, 02142
-
- Do apple growers tell their kids money doesn't grow on bushes?
-