From: Kevin on
Here is the result of my experiment.

Firstly, I created a file called "tmp.bin" in my local hard-drive and the size of this file is 20,000,000 bytes.

Then I do this in the Matlab command line:

datestr(now),
for n = 1:10,
movefile('tmp.bin', 'tmp1.bin');
movefile('tmp1.bin', 'tmp.bin');
end;
datestr(now)

ans =

01-Dec-2009 14:27:37


ans =

01-Dec-2009 14:27:48


So this means that it takes 10 seconds to do 20 file renames.

I am using P-4 with 2 GB memory and Windows XP.

I agree that I don't have a fast PC (in today standard) but I don't expect it takes that long to rename a file.

I don't think I have virus scan running on my PC.

I have done one more experiment. Reduce the file size to 200,000 (i.e. 100 times less) and now it takes less than 1 sec to do 20 renames.

Just think of one more thing to try. Instead of using MOVEFILE, I use dos('rename ...').

datestr(now),
for n = 1:10,
dos('rename tmp.bin tmp1.bin');
dos('rename tmp1.bin tmp.bin');
end;
datestr(now)

This takes 1 sec to do 20 renames for file szie = 20,000,000 bytes.

I also use the dos method on smaller file (200,000 bytes). It also takes 1 sec to do 20 renames.

So it is probably not Windows. It is somewhere else inside MOVEFILE.

In conclusion, it is faster to use dos('rename ....') than MOVEFILE to rename file. On Unix systems, we can use unix('mv ...').




"Kevin" <khung(a)fake.com> wrote in message <hf4217$j7h$1(a)fred.mathworks.com>...
> My scenario is very simple. I am just renaming a file in a directory in my local hard-drive, i.e. both source and destination files are in the same directory in my local hard-drive.
>
> But you have raised a good point about the virus scanner. I use AVG and I would not know what AVG does.
>
> "Steven Lord" <slord(a)mathworks.com> wrote in message <hf3ar4$p21$1(a)fred.mathworks.com>...
> >
> > "Kevin" <khung(a)fake.com> wrote in message
> > news:hf1hv8$2dn$1(a)fred.mathworks.com...
> > >I have seen this before but just don't have time to look into it. Actually
> > >there is not much that I can do since MOVEFILE is a built-in function.
> > >
> > > I use MOVEFILE to rename file but it seems to me that it takes some time
> > > if the file is large. This should not happen.
> >
> > Why not? If you've got a lot of bits to move, why shouldn't it take a while
> > to move them?
> >
> >
> > Are you using MOVEFILE with the source and destination file both on the same
> > local disk, or is one or both of the files on a network location?
> >
> > Do you have a (potentially overzealous) virus scanner that needs to scan the
> > file before or as it's moving?
> >
> > Is the disk to which you're moving the file heavily fragmented, so the OS
> > needs to search around a bit for places to put the pieces of the file?
> >
> > Is some other process accessing the disk at the same time, thus causing
> > contention for who gets to read/write at a given time?
> >
> > etc.
> >
> >
> > > Am I missing something?
> >
> > Yes. There are lots of reasons why MOVEFILE could take some time to move a
> > file. Now that being said, if it's taking an EXTREMELY long time (say
> > minutes for a few meg file) then you should contact whomever is in charge of
> > maintenance for the system on which you're running to make sure that the
> > machine is operating correctly, and if they give it a thumbs-up contact
> > MathWorks Technical Support.
> >
> > --
> > Steve Lord
> > slord(a)mathworks.com
> > comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
> >
From: dpb on
Kevin wrote:
....
> So it is probably not Windows. It is somewhere else inside MOVEFILE.
....
That does seem peculiar -- I at first was going to suggest that perhaps
movefile() is internally spawning a DOS session but the test of using
the system call seems to indicate that even that should be much quicker.

Seems like only recourse would be to follow S Lord's suggestion and send
this to TMW formal support for comment/action...

--
From: Kevin on
I don't have software maintenance for Matlab anymore and so probably I won't get an answer from Mathworks Tech Support.

Right?

dpb <none(a)non.net> wrote in message <hf47bu$msl$2(a)news.eternal-september.org>...
> Kevin wrote:
> ...
> > So it is probably not Windows. It is somewhere else inside MOVEFILE.
> ...
> That does seem peculiar -- I at first was going to suggest that perhaps
> movefile() is internally spawning a DOS session but the test of using
> the system call seems to indicate that even that should be much quicker.
>
> Seems like only recourse would be to follow S Lord's suggestion and send
> this to TMW formal support for comment/action...
>
> --
From: Rune Allnor on
On 1 Des, 04:59, "Kevin" <kh...(a)fake.com> wrote:
> Really!!! I am quite surprised any today OS would do that. I am using Windows Vista. I would think that even Windows would not even do that.

Run the script below with the file browser open.
The script stores 32MBytes of data in the file
test01.mat, and renames the file to test02.mat,
test03.mat, etc., up to test21.mat.

Under winXP and R2006a you can see that there are
two files present at any time; the source file
and destination file. In this configuration there
is in fact a file copy taking place.

Rune
From: Rune Allnor on
On 2 Des, 00:36, Rune Allnor <all...(a)tele.ntnu.no> wrote:
> On 1 Des, 04:59, "Kevin" <kh...(a)fake.com> wrote:
>
> > Really!!! I am quite surprised any today OS would do that. I am using Windows Vista. I would think that even Windows would not even do that.
>
> Run the script below with the file browser open.
> The script stores 32MBytes of data in the file
> test01.mat, and renames the file to test02.mat,
> test03.mat, etc., up to test21.mat.
>
> Under winXP and R2006a you can see that there are
> two files present at any time; the source file
> and destination file. In this configuration there
> is in fact a file copy taking place.
>
> Rune

It's well after midnight - forgot the code...:

A = randn(1000000,4);
save test01.mat A

tic
for n=1:20
sname = sprintf('test%02d.mat',n);
dname = sprintf('test%02d.mat',n+1);
movefile(sname,dname);
end
toc
delete(dname);
First  |  Prev  |  Next  |  Last
Pages: 1 2 3
Prev: Problem with bvp4c
Next: need help with problem PLEASE!!!