Fast compare two files binary # $Header: /CVSROOT/cmpfast/DESCRIPTION,v 1.3 2008-05-13 15:43:12 tino Exp $ # # $Log: DESCRIPTION,v $ # Revision 1.3 2008-05-13 15:43:12 tino # Standard return values on EOF # # Revision 1.2 2007-09-26 03:12:16 tino # Memory footprint decreased in most situations. # # Revision 1.1 2007/04/20 20:44:39 tino # Yet untested first version # This is just a binary compare for two files. Why another program as cmp does the job? cmp is not very fast when you read two files from the same hard drive. The problem is called "thrashing", as the read heads of the hard drive are moving wildly on the surface and effective read speed drops very low. cmpfast reads files in bigger blocks (by default 1 MB), thus reducing thrashing a lot. It also switches sides to double the continuously read blocks, thus speeding up fastcmp again. On modern fast hard drives you still hear a thrashing sound, this is because you still have 30 to 40 head movements per second to compare 30 MB or more per second. It would be not easy to go below this number, as it then needs a highly filesystem optimized low level access which is unlikely to be possible. So even cmpfast is very simple it's not easy to speed up more, even not if you raise the compare buffer size. 1 MB should be a good size for all possibilities. Cmpfast has following "standard" return values now:
* 0 (true) if everything ok (compares equal)
* 1 for usage etc.
* 10 if files differ in contents
* 101 if EOF on first file
* 102 if EOF on second file
* other return values (probably 255) on misc errors (like missing files)