Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #25720 > unrolled thread

deleting files

Started byRoedy Green <see_website@mindprod.com.invalid>
First post2011-01-28 11:00 -0800
Last post2011-01-28 18:05 -0400
Articles 3 — 3 participants

Back to article view | Back to comp.lang.java.programmer


Contents

  deleting files Roedy Green <see_website@mindprod.com.invalid> - 2011-01-28 11:00 -0800
    Re: deleting files Joshua Cranmer <Pidgeot18@verizon.invalid> - 2011-01-28 16:53 -0500
    Re: deleting files Arved Sandstrom <asandstrom3minus1@eastlink.ca> - 2011-01-28 18:05 -0400

#25720 — deleting files

FromRoedy Green <see_website@mindprod.com.invalid>
Date2011-01-28 11:00 -0800
Subjectdeleting files
Message-ID<kc46k65u61goegok3j9heoc5t5juh78k13@4ax.com>
I wrote a program to tidy up my hard disk. I run it as administrator.
It tells me there are a fair number of junk files I cannot delete. I
have a utility, presumably written in C, that much more rapidly scans
my drive for junk and manages to wipe out much of the junk I could
not.

I curious if anyone has experimented and could tell me:

1. why in the C utility is so much faster than my utility. My code is
basically just a bunch of File.list() with filters. What Java doing to
dither?

2. What is the utility doing to let it kill more files?
-- 
Roedy Green Canadian Mind Products
http://mindprod.com
To err is human, but to really foul things up requires a computer.
~ Farmer's Almanac
It is breathtaking how a misplaced comma in a computer program can
shred megabytes of data in seconds.

[toc] | [next] | [standalone]


#25726

FromJoshua Cranmer <Pidgeot18@verizon.invalid>
Date2011-01-28 16:53 -0500
Message-ID<ihvds0$19f$1@news.eternal-september.org>
In reply to#25720
On 01/28/2011 02:00 PM, Roedy Green wrote:
> I wrote a program to tidy up my hard disk. I run it as administrator.
> It tells me there are a fair number of junk files I cannot delete. I
> have a utility, presumably written in C, that much more rapidly scans
> my drive for junk and manages to wipe out much of the junk I could
> not.
>
> I curious if anyone has experimented and could tell me:
>
> 1. why in the C utility is so much faster than my utility. My code is
> basically just a bunch of File.list() with filters. What Java doing to
> dither?

It is possible that the utility could be reading disk blocks directly 
and reading the entire directly listing as it exists on the disk instead 
of using the OS APIs.

Another point of interest is that Java constructs the array by building 
a 16-element array, growing that à la ArrayList by doubles, and then 
copies that back into the output array, which could be slow for 
directories with a few thousand directory entries.

A final thing to note that it is possible that the utility is moving 
faster because the files it is checking is already cached. You should 
try observing the speed difference if you when the unknown utility first 
and then the Java utility later.

> 2. What is the utility doing to let it kill more files?

Of course, the real answer may be that the utility is doing something 
completely different which is faster than your approach. Listing 
directories can actually be very computationally expensive on FAT (and I 
think NTFS as well?) simply because of how the filesystem works...

-- 
Beware of bugs in the above code; I have only proved it correct, not 
tried it. -- Donald E. Knuth

[toc] | [prev] | [next] | [standalone]


#26151

FromArved Sandstrom <asandstrom3minus1@eastlink.ca>
Date2011-01-28 18:05 -0400
Message-ID<e4H0p.22366$3K.2330@newsfe12.iad>
In reply to#25720
On 11-01-28 03:00 PM, Roedy Green wrote:
> I wrote a program to tidy up my hard disk. I run it as administrator.
> It tells me there are a fair number of junk files I cannot delete. I
> have a utility, presumably written in C, that much more rapidly scans
> my drive for junk and manages to wipe out much of the junk I could
> not.
>
> I curious if anyone has experimented and could tell me:
>
> 1. why in the C utility is so much faster than my utility. My code is
> basically just a bunch of File.list() with filters. What Java doing to
> dither?
>
> 2. What is the utility doing to let it kill more files?

What this really comes down to is (as others have suggested), what's 
your definition of a "junk" file? It obviously differs from the common 
approaches used by industrial junk file removal programs, because I 
doubt any of those are going to be using too much (if any) of a 
"String[] list(FilenameFilter filter)" mechanism...in whatever language 
they are written in.

AHS

-- 
So I listened to that Sputnik moment talk over and over again, and I 
think, No, we don't need one of those. You know what we need is a 
"spudnut" moment.
-- Sarah Palin, commenting on SOTU address

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.java.programmer


csiph-web