Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the Spreadsheet-ParseExcel CPAN distribution.

Maintainer(s)' notes

If you are reporting a bug in Spreadsheet::ParseExcel here are some pointers

1) State the issues as clearly and as concisely as possible. A simple program or Excel test file (see below) will often explain the issue better than a lot of text.

2) Provide information on your system, version of perl and module versions. The following program will generate everything that is required. Put this information in your bug report.

    #!/usr/bin/perl -w

    print "\n    Perl version   : $]";
    print "\n    OS name        : $^O";
    print "\n    Module versions: (not all are required)\n";

    my @modules = qw(
                      Spreadsheet::ParseExcel
                      Scalar::Util
                      Unicode::Map
                      Spreadsheet::WriteExcel
                      Parse::RecDescent
                      File::Temp
                      OLE::Storage_Lite
                      IO::Stringy
                    );

    for my $module (@modules) {
        my $version;
        eval "require $module";

        if (not $@) {
            $version = $module->VERSION;
            $version = '(unknown)' if not defined $version;
        }
        else {
            $version = '(not installed)';
        }

        printf "%21s%-24s\t%s\n", "", $module, $version;
    }

    __END__

3) Upgrade to the latest version of Spreadsheet::ParseExcel (or at least test on a system with an upgraded version). The issue you are reporting may already have been fixed.

4) Create a small example program that demonstrates your problem. The program should be as small as possible. A few lines of codes are worth tens of lines of text when trying to describe a bug.

5) Supply an Excel file that demonstrates the problem. This is very important. If the file is big, or contains confidential information, try to reduce it down to the smallest Excel file that represents the issue. If you don't wish to post a file here then send it to me directly: jmcnamara@cpan.org

6) Say if the test file was created by Excel, OpenOffice, Gnumeric or something else. Say which version of that application you used.

7) If you are submitting a patch you should check with the maintainer whether the issue has already been patched or if a fix is in the works. Patches should be accompanied by test cases.

Asking a question

If you would like to ask a more general question there is the Spreadsheet::ParseExcel Google Group.

Report information
The Basics
Id: 42518
Status: resolved
Worked: 30 min
Priority: 0/
Queue: Spreadsheet-ParseExcel

People
Owner: Nobody in particular
Requestors: gfuji [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: (no value)
Fixed in: (no value)



Subject: lvalue substr() is slow
Hello, I have profiled my application using S::ParseExcel, and it is shown that lvalue substr() seems to make Spreadsheet::ParseExcel::Utility::ExcelFmt a bottleneck. The attached file simply replaces all the callings of lvalue substr() to those of 4-args substr(). Could you please apply it to Utility.pm? Regards, -- Goro Fuji (GFUJI at CPAN.org)
Subject: Utility.diff
--- Spreadsheet-ParseExcel-0.44-orig/lib/Spreadsheet/ParseExcel/Utility.pm 2009-01-09 12:09:52.000000000 +0900 +++ Spreadsheet-ParseExcel-0.44/lib/Spreadsheet/ParseExcel/Utility.pm 2009-01-19 11:59:39.995710400 +0900 @@ -558,14 +558,14 @@ } #print "REP:$sRep ",$rItem->[0], ":", $rItem->[1], ":" ,$rItem->[2], "\n"; - substr( $sFmtRes, $rItem->[1], $rItem->[2] ) = $sRep; + substr( $sFmtRes, $rItem->[1], $rItem->[2], $sRep ); } } elsif ( ( $iFmtMode == 1 ) && ( $iData =~ /$sNUMEXP/ ) ) { if ( $#aRep >= 0 ) { while ( $aRep[$#aRep]->[0] eq ',' ) { $iCmmCnt--; - substr( $sFmtRes, $aRep[$#aRep]->[1], $aRep[$#aRep]->[2] ) = ''; + substr( $sFmtRes, $aRep[$#aRep]->[1], $aRep[$#aRep]->[2], '' ); $iData /= 1000; pop @aRep; } @@ -644,42 +644,42 @@ if ( $rItem->[0] =~ /([#0]*)([\.]?)([0#]*)([eE])([\+\-])([0#]+)/ ) { - substr( $sFmtRes, $rItem->[1], $rItem->[2] ) = - MakeE( $rItem->[0], $iData ); + substr( $sFmtRes, $rItem->[1], $rItem->[2], + MakeE( $rItem->[0], $iData ) ); } elsif ( $rItem->[0] =~ /\// ) { - substr( $sFmtRes, $rItem->[1], $rItem->[2] ) = - MakeBun( $rItem->[0], $iData, $iInt ); + substr( $sFmtRes, $rItem->[1], $rItem->[2], + MakeBun( $rItem->[0], $iData, $iInt ) ); } elsif ( $rItem->[0] eq '.' ) { $iLen--; $iPPos = $iLen; } elsif ( $rItem->[0] eq '+' ) { - substr( $sFmtRes, $rItem->[1], $rItem->[2] ) = - ( $iData > 0 ) ? '+' : ( ( $iData == 0 ) ? '+' : '-' ); + substr( $sFmtRes, $rItem->[1], $rItem->[2], + ( $iData > 0 ) ? '+' : ( ( $iData == 0 ) ? '+' : '-' ) ); } elsif ( $rItem->[0] eq '-' ) { - substr( $sFmtRes, $rItem->[1], $rItem->[2] ) = - ( $iData > 0 ) ? '' : ( ( $iData == 0 ) ? '' : '-' ); + substr( $sFmtRes, $rItem->[1], $rItem->[2], + ( $iData > 0 ) ? '' : ( ( $iData == 0 ) ? '' : '-' ) ); } elsif ( $rItem->[0] eq '@' ) { - substr( $sFmtRes, $rItem->[1], $rItem->[2] ) = $iData; + substr( $sFmtRes, $rItem->[1], $rItem->[2], $iData ); } elsif ( $rItem->[0] eq '*' ) { - substr( $sFmtRes, $rItem->[1], $rItem->[2] ) = ''; #REMOVE + substr( $sFmtRes, $rItem->[1], $rItem->[2], '' ); #REMOVE } elsif (( $rItem->[0] eq "\xA2\xA4" ) or ( $rItem->[0] eq "\xA2\xA5" ) or ( $rItem->[0] eq "\x81\xA2" ) or ( $rItem->[0] eq "\x81\xA3" ) ) { - substr( $sFmtRes, $rItem->[1], $rItem->[2] ) = $rItem->[0]; + substr( $sFmtRes, $rItem->[1], $rItem->[2], $rItem->[0] ); # ($iData > 0)? '': (($iData==0)? '':$rItem->[0]); } elsif ( ( $rItem->[0] eq '(' ) or ( $rItem->[0] eq ')' ) ) { - substr( $sFmtRes, $rItem->[1], $rItem->[2] ) = $rItem->[0]; + substr( $sFmtRes, $rItem->[1], $rItem->[2], $rItem->[0] ); # ($iData > 0)? '': (($iData==0)? '':$rItem->[0]); } @@ -707,8 +707,7 @@ else { $sRep = ''; } - substr( $sFmtRes, $rItem->[1], $rItem->[2] ) = - "\x00" . $sRep; + substr( $sFmtRes, $rItem->[1], $rItem->[2], "\x00" . $sRep ); } } $sRep = ( $iLen > 0 ) ? substr( $sNumRes, 0, $iLen ) : ''; @@ -721,11 +720,11 @@ for ( my $iIt = $#aRep ; $iIt >= 0 ; $iIt-- ) { my $rItem = $aRep[$iIt]; if ( $rItem->[0] eq '@' ) { - substr( $sFmtRes, $rItem->[1], $rItem->[2] ) = $iData; + substr( $sFmtRes, $rItem->[1], $rItem->[2], $iData ); $iAtMk++; } else { - substr( $sFmtRes, $rItem->[1], $rItem->[2] ) = ''; + substr( $sFmtRes, $rItem->[1], $rItem->[2], $iData ); } } $sFmtRes = $iData unless ($iAtMk); @@ -742,7 +741,7 @@ if ( $sNum =~ /^([^\d]*)(\d\d\d\d+)(\.*.*)$/ ) { my ( $sPre, $sObj, $sAft ) = ( $1, $2, $3 ); for ( my $i = length($sObj) - 3 ; $i > 0 ; $i -= 3 ) { - substr( $sObj, $i, 0 ) = ','; + substr( $sObj, $i, 0, q{,} ); } return $sPre . $sObj . $sAft; }
On Mon Jan 19 02:57:20 2009, GFUJI wrote: Show quoted text
> Hello, > > I have profiled my application using S::ParseExcel, and it is shown that > lvalue substr() seems to make Spreadsheet::ParseExcel::Utility::ExcelFmt > a bottleneck.
Hi, I'm actually in the process of refactoring ExcelFmt() quite significantly. It would be useful to have a Benchmark.pm testcase if you have one since there is also the slowdown caused by the use of $& (RT 42425). If you have a benchmark testcase could you post it. John. --
Subject: Re: [rt.cpan.org #42518] lvalue substr() is slow
Date: Tue, 20 Jan 2009 17:12:10 +0900
To: bug-Spreadsheet-ParseExcel [...] rt.cpan.org
From: Goro Fuji <gfuji [...] cpan.org>
2009/1/19 John McNamara via RT <bug-Spreadsheet-ParseExcel@rt.cpan.org>: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=42518 > > > On Mon Jan 19 02:57:20 2009, GFUJI wrote:
>> Hello, >> >> I have profiled my application using S::ParseExcel, and it is shown that >> lvalue substr() seems to make Spreadsheet::ParseExcel::Utility::ExcelFmt >> a bottleneck.
> > > Hi, > > I'm actually in the process of refactoring ExcelFmt() quite significantly. > > It would be useful to have a Benchmark.pm testcase if you have one since there is also the > slowdown caused by the use of $& (RT 42425). > > If you have a benchmark testcase could you post it.
Oh, very good job! The excel files I profiled are private, but FYI, I profiled them with Devel::NYTProf, which is a nice, easy profiler. Regards, -- Goro Fuji (藤 吾郎)
Hi, Fixed in version 0.46. Thanks, John. --