[geos-devel] gprof (missing attachment)

strk at refractions.net strk at refractions.net
Sun Feb 6 09:11:02 EST 2005


I've found out that while profiling I had compiler
optimizations turned off. This augmented a lot STL timings..

Here are top lines of new -O2 profiling for buffer 500:

  %   cumulative   self              self     total                              time   seconds   seconds    calls   s/call   s/call  name
 13.51      2.33     2.33  7962785     0.00     0.00  geos::Envelope::intersects(geos::Envelope const*) const
  8.52      3.80     1.47    54569     0.00     0.00  geos::AbstractSTRtree::query(void const*, geos::AbstractNode*, std::vector<void*, std::allocator<void*> >*)
  4.12      4.51     0.71   755477     0.00     0.00  geos::RobustDeterminant::signOfDet2x2(double, double, double, double)
  3.77      5.16     0.65   279274     0.00     0.00  geos::RobustLineIntersector::computeIntersect(geos::Coordinate const&, geos::Coordinate const&, geos::Coordinate const&, geos::Coordinate const&)
  3.30      5.73     0.57  3106372     0.00     0.00  geos::Envelope::getMaxY() const
  2.72      6.20     0.47  7546996     0.00     0.00  geos::STRtree::STRIntersectsOp::intersects(void const*, void const*)


The Envelope::GetMaxY definitely needs inlining. Probably most of Envelope
methods should.

--strk;

On Sun, Feb 06, 2005 at 01:28:30PM +0100, strk at refractions.net wrote:
> Sorry, I didn't specify that, the function is this, already
> optimized:
> 
> bool
> Envelope::intersects(const Envelope* other) const
> {
>         // Optimized to reduce function calls
>         if ( isnull ) return false;
>         return !(other->minx > maxx ||
>                          other->maxx < minx ||
>                          other->miny > maxy ||
>                          other->maxy < miny);
> }
> 
> Note that isnull is a bool, original code called ::isNull, a step
> after I've inlined it using maxx<minx || maxy<miny. Currenlty it
> is a single bool check.
> Maybe the return !(expr) is not optimized by the compiler, but I'm 
> not sure at that would be simple.... first expression evaluating
> to false should prevent further checkings. Am I wrong ?
> 
> Inlining it should have some benefits as the function is invoked
> 269666299 times (for buffer2000).
> 
> --strk;
> 
> On Sun, Feb 06, 2005 at 07:02:05AM -0500, Norman Vine wrote:
> > If this is actually a hotspot probably best to take advantage
> > of all the apriori knowledge we can :-)
> > 
> > < I think this is correct some one should check my logic though >
> > 
> > bool Envelope::intersects(const Coordinate& p1,const Coordinate& p2,const Coordinate& q1,const Coordinate& q2)
> > {
> > /* please leave this commented code as documentation 
> >     if( min(p1.x,p2.x) > max(q1.x,q2.x) ||
> >           max(p1.x,p2.x) < min(q1.x,q2.x) ||
> >           min(p1.y,p2.y) > max(q1.y,q2.y) ||
> >           max(p1.y,p2.y) < min(q1.y,q2.y) )
> >         return false;
> >     return true;
> > */
> > 
> >     if( p1.x < p2.x )  {
> >         if( q1.x > q2.x )  {
> >             if( p1.x > q1.x )  return false;
> >             if( p2.x < q2.x )  return false;
> >         } else {
> >             if( p1.x > q2.x )  return false;
> >             if( p2.x < q1.x )  return false;
> >         }
> >     } else {
> >         if( q1.x > q2.x )  {
> >             if( p2.x > q1.x )  return false;
> >             if( p1.x < q2.x )  return false;
> >         } else {
> >             if( p2.x > q2.x )  return false;
> >             if( p1.x < q1.x )  return false;
> >         }
> >     }
> > 
> >     if( p1.y < p2.y ) {
> >         if( q1.y > q2.y )  {
> >             if( p1.y > q1.y )  return false;
> >             if( p2.y < q2.y )  return false;
> >         } else {
> >             if( p1.y > q2.y )  return false;
> >             if( p2.y < q1.y )  return false;
> >         }
> >     } else {
> >         if( q1.y > q2.y ) {
> >             if( p2.y > q1.y )  return false;
> >             if( p1.y < q2.y )  return false;
> >         } else {
> >             if( p2.y > q2.y )  return false;
> >             if( p1.y < q1.y )  return false;
> >         }
> >     }
> >     return true;
> > }
> > 
> > _______________________________________________
> > geos-devel mailing list
> > geos-devel at geos.refractions.net
> > http://geos.refractions.net/mailman/listinfo/geos-devel
> _______________________________________________
> 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