Skip Menu |

This queue is for tickets about the GD-Graph-Cartesian CPAN distribution.

Report information
The Basics
Id: 75889
Status: resolved
Worked: 2 hours (120 min)
Priority: 0/
Queue: GD-Graph-Cartesian

People
Owner: MRDVT [...] cpan.org
Requestors: MRDVT [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 0.06
Fixed in: 0.07



Subject: GD-Graph-Cartesian min/max cache is broken
From: Colin Goddard at discuva.com Sent: Monday, March 19, 2012 8:57 AM Hi Michael, This is an extremely useful module, but it looks like you intended to make the following changes, then never got around to it. In sub maxy{} you have the following code:- sub maxy { my $self=shift(); unless (defined($self->{'maxy'})) { my ($min, $max)=$self->_minmaxy; $self->{'maxy'}=$max; } return $self->{'maxy'}; } The line:- unless (defined($self->{'maxy'})) { means that _minmaxy is only called once by this method, which is good for large data sets, as _minmaxy performs a sort on all data; points, lines and text. Unfortunately, minx, miny and maxx do not have the unless (defined($self->{'mxxx'})) { so they call the sort routine every time they are called, such as for every point they plot or line they draw. For a data-set of 4500 points, this can take more than 30 seconds to plot. By updating them to the following, the draw time can be reduced to 0.1 sec for a dataset of this size:- =head2 minx =cut sub minx { my $self=shift(); unless (defined($self->{'minx'})) { my ($min, $max)=$self->_minmaxx; $self->{'minx'}=$min; } return $self->{'minx'}; } =head2 maxx =cut sub maxx { my $self=shift(); unless (defined($self->{'maxx'})) { my ($min, $max)=$self->_minmaxx; $self->{'maxx'}=$max; } return $self->{'maxx'}; } =head2 miny =cut sub miny { my $self=shift(); unless (defined($self->{'miny'})) { my ($min, $max)=$self->_minmaxy; $self->{'miny'}=$min; } return $self->{'miny'}; } Regards, Colin Goddard
Colin, I just want to say thanks for reporting this. I've had this package running for a log time. I was not really paying attention to the performance but it's like night and day on my big charts. I have uploaded an updated version to a CPAN mirror near you GD-Graph- Cartesian-0.07.tar.gz The API is 100% the same but I've changed things internally quite a bit. 0.07 2012-03-19 - Updated package with my current best practices - Objects are Lazy loaded - Moved all initializing to methods - Use first and minmax from utils - Added tests kwalitee.t, changes.t, and pod-coverage.t - Fixed performance issue where minmax was not being cached correctly - Colin Goddard at discuva.com Thanks, Mike