groovy-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Russel Winder <rus...@winder.org.uk>
Subject Re: gpars for calculating directory content size
Date Fri, 16 Jun 2017 16:53:00 GMT
On Fri, 2017-06-16 at 14:55 +0000, Merlin Beedell wrote:
> I see that groovy has a handy method to return the sum of file & sub-
> directory sizes in a directory:
> new File('sample').directorySize()
> 
> But I would be interested to see if the underlying code uses gpars -
> on the assumption that the computation would be faster if sub-
> directories are found (the sum of each being performed in parallel).

No it just uses eachFileRecurse which is a single threaded recursive
walk over a file system.

     |> time du -s .
    340380    	    .

    real    	    0m0.033s
    user    	    0m0.007s
    sys    	    0m0.026s

    |> time groovy -e "println(new File('.').directorySize())"
    332167942

    real    	    0m1.215s
    user    	    0m2.081s
    sys    	    0m0.169s

I am sure you could do a fork/join version of eachFileRecurse, but I am
not sure there is one.

[…]
-- 
Russel.
=============================================================================
Dr Russel Winder      t: +44 20 7585 2200   voip: sip:russel.winder@ekiga.net
41 Buckmaster Road    m: +44 7770 465 077   xmpp: russel@winder.org.uk
London SW11 1EN, UK   w: www.russel.org.uk  skype: russel_winder
Mime
View raw message