Code covered by the BSD License  

Highlights from
cmp: a pedestrian yet very fast file comparator

3.33333

3.3 | 3 ratings Rate this file 0 Downloads (last 30 days) File Size: 3.1 KB File ID: #14596
image thumbnail

cmp: a pedestrian yet very fast file comparator

by us

 

10 Apr 2007 (Updated 11 Apr 2007)

CMP compares two files byte by byte

| Watch this File

File Information
Description

CMP compares two files byte by byte employing a speed and memory optimized engine.
if the files do not match, CMP prints/returns the position and the numerical and ASCII character representation of the first differing byte and its ten neighbors.

performance:

% create a file with 80 megabytes of random data
fnam='cmp_test.mat';
tmat=rand(1,10*2^20);
save(fnam,'tmat');
clear tmat;
tic;
r=cmp(fnam,fnam,'-b','-s');
toc
delete(fnam);

% wintel systems:
% 1) p5/1.6ghz/512mb/win2k/r2007a
% > elapsed time = 3.7021 seconds
% 2) p5/2.6ghz/512mb/winxp/r2007a
% > elapsed time = 2.1013 seconds
% 3) c2.2*2.4ghz/2gb/winvista/r2007a
% > elapsed time = 1.0190 seconds

see
> help cmp
and the screen shot for more information about this self-explanatory snippet and its few options.

MATLAB release MATLAB 7 (R14)
Other requirements good spirits!
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (4)
17 Apr 2007 x y

Why does this submission keep appearing, then disappearing? At least this time it is not called "pedestrian". When will you elitists, Us, John, Duane, Jos, etc. stop being so harsh in criticizing submissions just because they are created by nonprofessionals?

17 Apr 2007 urs (us) schwarz

dear reviewer, you are correct: i took the liberty to remove previous versions of this snippet because of uncommented ratings, which eventually spiraled into a ridiculous star-war.
THIS TIME you took the time to comment on your rating - i really do not care about the stars - as long as they are based on some thoughts.
In addition, i will cherish this review all the more as it puts me on the same level as some of our true ML role models like john (d'errico, i assume), duane (hanselman), and jos (van der geest).
us

17 Apr 2007 John D'Errico

Whoever this "x y" is, this individual has improperly singled out a worthy contribution to the FEX. CMP has excellent help, an H1 line, carefully written modular code, error checks, it is speedy and works on any system. Urs has, as always, provided a well crafted code.

I'd add only one line to the help. I tested the code out on an m-file on my search path. This failed, so at first I assumed this code did not run on m-files. This seemed wrong, so I looked deeper, to realize that the file names must include the full path if they do not lie in the current directory. While this is indeed an eminently logical behavior, the help for cmp states only that the file name must include any extensions. An alternative would be to add a call to which if a file does not appear in the directory listing.

10 Jul 2007 Ali OZGUL

I was tested this programs application on several computer platforms with different operation systems[]. Program documantation and code-write-style is not-regular although this submission don't merit comments as poor review.

Good works, Best Regards

[]: MSI-K9Neo-Platinium, AMD-Athlon 64bit 3GHZ,2000-Fsb,1GB Dual-Ram,Non-overclok,
Elapsed time : 1.023452 second (Microsoft-Windows-Xp(Sp2)
Elapsed time : 1.053245 second (Suse-linux 9.0)

Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
path us 22 Oct 2008 09:08:31
directories us 22 Oct 2008 09:08:31
files us 22 Oct 2008 09:08:31
file us 22 Oct 2008 09:08:31
bit us 22 Oct 2008 09:08:31
byte us 22 Oct 2008 09:08:31
contents us 22 Oct 2008 09:08:31
speed us 22 Oct 2008 09:08:31
comparison us 22 Oct 2008 09:08:31

Contact us at files@mathworks.com