filecmp.dircmp performance

D

dads

I'm creating a one way sync program, it's to automate backing up data
over the wan from our shops to a server at head office. It uses
filecmp.dircmp() but the performance seems poor to me.

for x in dc.diff_files:
srcfp = os.path.join(src, x)
self.fn777(srcfp)
if os.path.isfile(srcfp):
try:
shutil.copy2(srcfp, dst)
self.lg.add_diffiles(src, x)
except Exception, e:
self.lg.add_errors(e)

I tested it at a store which is only around 50 miles away on a 10Mbps
line, the directory has 59 files that are under 100KB. When it gets to
dc.diff_files it takes 15mins to complete. Looking at the filecmp.py
it's only using os.stat, it seems excessively long.

code:
http://pastebin.com/QskXGDQT
 
P

Peter Otten

dads said:
I'm creating a one way sync program, it's to automate backing up data
over the wan from our shops to a server at head office. It uses
filecmp.dircmp() but the performance seems poor to me.

for x in dc.diff_files:
srcfp = os.path.join(src, x)
self.fn777(srcfp)
if os.path.isfile(srcfp):
try:
shutil.copy2(srcfp, dst)
self.lg.add_diffiles(src, x)
except Exception, e:
self.lg.add_errors(e)

I tested it at a store which is only around 50 miles away on a 10Mbps
line, the directory has 59 files that are under 100KB. When it gets to
dc.diff_files it takes 15mins to complete. Looking at the filecmp.py
it's only using os.stat, it seems excessively long.

As a baseline it would be interesting to see how long it takes to copy those
59 files using system tools.

However, there are efficient tools out there that work hard to reduce the
traffic over the net which is likely to be the bottleneck. I suggest that
you have have a look at

http://en.wikipedia.org/wiki/Rsync
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,008
Latest member
Rahul737

Latest Threads

Top