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

Glynn Clements glynn at gclements.plus.com
Wed Sep 12 09:54:20 EDT 2007


Markus Neteler wrote:

> >>> The main thing which stands out is that it invokes "grep" once for
> >>> every name returned by g.list:
> >>>       
> >> 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.
> >>     
> >
> > Here's my proposed alternative. It avoids the use of backticks in
> > favour of a pipeline ending in a while loop.
> >
> >   
> It appears that Hamish's implementation based on Glynn's former notes
> is much faster:
> 
> time sh g.mlist_glynn type=rast map=neteler pat="map*"
> real    0m1.200s
> user    0m0.749s
> sys     0m0.464s
> 
> time sh g.mlist_hamish type=rast map=neteler pat="map*"
> real    0m0.338s
> user    0m0.190s
> sys     0m0.052s
> 
> Is that the contribution to portability? :)

I had overlooked the part where loop which adds the separator was
replaced with a call to "tr".

Technically, this corresponds to a reduction in functionality, as the
previous version would accept any string as a separator, but using
"tr" restricts it to a single character (which is probably all that's
required).

I've committed an update which has no loops other than the top-level
"for mapset in $mapsets" loop.

-- 
Glynn Clements <glynn at gclements.plus.com>




More information about the grass-dev mailing list