[GRASS-dev] g.mlist as C implementation?

Markus Neteler neteler at itc.it
Mon Sep 10 11:09:20 EDT 2007


Hamish wrote on 09/10/2007 05:52 AM:
> Glynn Clements wrote:
>   
>> Markus Neteler wrote:
>>     
>>> when using g.mlist in mapsets with thousands of maps in
>>> it (as happens with MODIS time series), it gets extremely
>>> slow.
>>>       
> ..
> Glynn Clements wrote:
>   
>> The main thing which stands out is that it invokes "grep" once for
>> every name returned by g.list:
>>     
>
>
> Hi,
>
> see attached patch for consideration. Following Glynn's suggestion it
> gets rid of the loop for each map name, making the script ~50% faster
> than before, but still about twice as slow as a single call to g.list.
>
> I haven't put it in CVS as I haven't really tested it.
>
>   
I have made these tests:

for i in `seq 1 2000` ; do r.mapcalc map$i=1 ;done
# old g.mlist
time g.mlist type=rast pat="map*"
real    0m7.496s
user    0m2.417s
sys     0m4.983s

# new g.mlist
time g.mlist type=rast pat="map*"
real    0m0.230s
user    0m0.157s
sys     0m0.058s

=> 0.230/7.496 = 0.031

for i in `seq 1 10000` ; do r.mapcalc map$i=1 ;done
# old g.mlist
real    0m54.725s
user    0m24.809s
sys     0m28.944s

# new g.mlist
real    0m0.416s
user    0m0.229s
sys     0m0.087s

=> 0.416/54.725 = 0.0076

# paranoia test: new g.mlist
g.mlist type=rast pat="map*" | wc -l
10000

Amazing!
Also g.mremove will be finally fast then since it calls g.mlist.

Markus

------------------
ITC -> dall'1 marzo 2007 Fondazione Bruno Kessler
ITC -> since 1 March 2007 Fondazione Bruno Kessler
------------------




More information about the grass-dev mailing list