home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 1 / 1901 < prev    next >
Encoding:
Internet Message Format  |  1990-12-28  |  2.1 KB

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