It seems io.Copy is slow for me:
_,err = io.Copy(destf,srcf)
io.Copy takes longer, about 2 minutes to copy a 1GB file to a network share. Noticed that mv.exe finishes the job in ~25 seconds max - so I've started to evoke mv for my jobs.
output, err := exec.Command("mv", src, dest_folder).CombinedOutput()
This slowness is consistently reproducible on my end, Any tips on how to speeden will be much appreciated!
Update:
Thanks for the suggestion to use io.CopyBuffer()
, however mv.exe
still emerges as the sole victor, by a respectable margin.
Details:
PS C:\temp> .\move_files.exe .\testfile.data "\\somehost\somefolder\bleh13.txt"
2018/07/14 19:04:54 Created C:\Temp\2\deleteME__913153343, copy of .\testfile.data, Size: 1073745920 bytes
2018/07/14 19:05:55 Transfer with io.Copy() took us 60.836702 seconds
2018/07/14 19:06:47 Transfer with io.CopyBuffer() took us 50.729625 seconds
2018/07/14 19:06:59 Transfer with mv command took us 11.470456 seconds
PS C:\temp>
You're welcome to try this yourself : https://play.golang.org/p/2_lR83A4BXe