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

David Blasby dblasby at refractions.net
Thu Nov 14 19:15:17 EST 2002


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





More information about the geos-devel mailing list