My app has a lot of reloading of the plot ranges and hence the axes need to
recalculate the labeling fairly often. It turned out that despite all the heavy
algebra going on in the app and all the drawing, more than 10% of processor
time was spent on dividing decimal numbers in one particular method on the plot
space. It was called by CPTXYAxis'
viewPointForOrthogonalCoordinateDecimal:axisCoordinateDecimal: method.
Since this method returns a (floating point based) CGPoint anyway, I would
suggest using the double-precision methods of the plot space and avoid the
extremely costly decimal division. Implemented like this, this whole method
disappears from the radar in the Instruments entirely:
-(CGPoint)viewPointForOrthogonalCoordinateDecimal:(NSDecimal)orthogonalCoord
axisCoordinateDecimal:(NSDecimal)coordinateDecimalNumber
{
CPTCoordinate myCoordinate = self.coordinate;
CPTCoordinate orthogonalCoordinate = CPTOrthogonalCoordinate(myCoordinate);
double plotPoint[2];
plotPoint[myCoordinate] = CPTDecimalDoubleValue(coordinateDecimalNumber);
plotPoint[orthogonalCoordinate] = CPTDecimalDoubleValue(orthogonalCoord);
return [self convertPoint:[self.plotSpace plotAreaViewPointForDoublePrecisionPlotPoint:plotPoint] fromLayer:self.plotArea];
}
Original issue reported on code.google.com by sergiy.p...@gmail.com on 30 Jan 2012 at 8:34
Original issue reported on code.google.com by
sergiy.p...@gmail.com
on 30 Jan 2012 at 8:34