Why is cp command 4 times slower than copying in Finder in OS X 10.6?
I accidentally stumbled upon this issue:
Copying a 119 MB zip file took 4 times longer in Terminal (cp) than in Finder!
I copied a file of 119 MB size in Terminal with time cp file.zip file2.zip
and it took about 20 seconds.
As this seemed quite slow to me, I went to the Finder, selected the same file and hit Cmd-D
(duplicate) and it took less than 5 seconds to create the copy, that is only 25% of the time it took with cp!
Is there an explanation for it - might this be systematic?
Used Hard-/Software
- MacBook 13" white (2007)
- OS X 10.6.8
- Internal hard disk WDC WD10JPVT-00A1YT0
it really seems to be a cache issue: I tried the opposite order with another file and copied it first in Finder and then in Terminal, and in this case also the second copying was much faster.
Since I have a much newer system, I couldn't accurately test with a 119 MB file as it took less than a second to copy in Terminal. So I created several much larger files, up to 2 GB, using dd
and /dev/random
as the source and made duplicates. I then rebooted and then did timed copies of each of the sets, one in Terminal and the other in Finder. This way, there was nothing in the disk cache/memory during the subsequent copy operations in each app for each set.
The timings were near identical, so near as to be the same for this test purpose. I say near identical as in Terminal I used the time
command and in Finder I used the second hand of the clock. So in your case, the file definitely was still in memory when the second copy operation was performed.