divyavamsee / core-plot

Automatically exported from code.google.com/p/core-plot
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

CPTXYAxis performance #399

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
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

GoogleCodeExporter commented 9 years ago

Original comment by eskr...@mac.com on 3 Feb 2012 at 3:10

GoogleCodeExporter commented 9 years ago
This issue was closed by revision bc9f70c4dac4.

Original comment by eskr...@mac.com on 3 Feb 2012 at 3:13