Performance

"henningmllernielsen" <henning.just-B5obmGyaMydknbxzx/[email protected]> Thu, 20 Nov 2008 08:14:25 -0000
Newsgroups gmane.comp.lang.perl.modules.pdfapi2
Message-ID <[email protected]>
Hi everyone - especially our dear creator and maintainer of PDF::API2.

We are running some very complex PDF generation with PDF::API2 and are
very impressed. Unfortunately they are becoming quite time consuming
so we have tried profiling the scripts and modules.

We have used the new Devel::NYTProf.

Now, we'd love to help with suggestions but are unsure where to send
them - would this list be the right place? Or should we send them to
an email address? Or is there a SVN repository somewhere?

Anyway, one suggestion is to change this in
PDF::API2::Resource::CIDFont::TrueType (line 145-148)

    if(defined $self->fontobj->{'hmtx'}->read->{'advance'}[$g]) 
    {
        $w =
int($self->fontobj->{'hmtx'}->read->{'advance'}[$g]*1000/$self->data->{upem});
    } 

to

    my $temp_value = $self->fontobj->{'hmtx'}->read->{'advance'}[$g];
    if(defined $temp_value) 
    {
        $w = int($temp_value*1000/$self->data->{upem});
    } 

In one of our realistic tests this little change alone could reduce
more than 1% of the time spent. There are lots of these little changes
all over the place and we'd love to help spot them.

/Henning