[geos-devel] Coordinate & Coordinate list (20% faster now)

Martin Davis mbdavis at VividSolutions.com
Thu Nov 14 19:17:43 EST 2002


Excellent - shows we're on the right track.

I wonder how much ditching the use of vector really saves?  Aren't most of the vector functions inlined?  However, it should be pretty easy & secure to implement a coordinate array directly instead of a vector, so it's worth trying.

Martin Davis, Senior Technical Specialist
Vivid Solutions Inc.
Suite #1A-2328 Government Street   Victoria, B.C.   V8T 5G5
Phone: (250) 385 6040    Fax: (250) 385 6046
EMail: mbdavis at vividsolutions.com  Web: www.vividsolutions.com


> -----Original Message-----
> From: David Blasby [mailto:dblasby at refractions.net]
> Sent: Thursday, November 14, 2002 4:15 PM
> To: geos-devel at geos.refractions.net
> Subject: Re: [geos-devel] Coordinate & Coordinate list (20% 
> faster now)
> 
> 
> I tested my theory:
> 
> 
> 50,000 points TestSweepLineSpeed
> 
> takes about 10.2 seconds on my machine
> 
> I changed CoordinateList's getAt(int) from:
> 
> Coordinate CoordinateList::getAt(int pos)
> {
>         moveTo(pos);
>         return get();
> }
> 
> to:
> 
> Coordinate CoordinateList::getAt(int pos)
> {
>     if ((pos>vect->size()-1) || (pos<0) )
>          throw "Invalid argument: out of bounds\n" ;
>     else
>         current=pos;
>     return (*vect)[current];
> }
> 
> This is *exactly* the same code, but I pulled the MoveTo() 
> and get() into the function.  This should only really save 2 
> function call overheads and one call to the copy constructor.
> 
> The results is 8.2 seconds.  Thats 20% faster!!!
> 
> So, the CooridinateList is a pretty key code portion!
> 
> 
> We could probably save a bunch more time by:
>     actually implementing the vector in the class (save a 
> bunch of class calling overhead)
>     returning pointers instead of actual objects
> 
> 
> I'd love to see the Copy Constructor called only 50,000 times 
> for a 50,000 point input set.
> 
> dave
> 
> 
> _______________________________________________
> geos-devel mailing list
> geos-devel at geos.refractions.net
> http://geos.refractions.net/mailman/listinfo/geos-devel
> 




More information about the geos-devel mailing list