Hello PerlMonks,

I have inherited from another person some Perl scripts dealing with logfile manipulation. The idea is simple, read data from some text file, decode it and write the results in an Excel file. The script is working ok, but it takes a huge amount of time to finish, even though the log files are not that big (30MB max). Moreover, the script runs 10x faster on my colleague machine. I use Win32::OLE to deal with Excel manipulation as I also need to do some formatting on the output.

To find out which parts of the code are slow I have done a profiling of my application using Devel::NYTProf and I have found some interesting results. A snippet of the code is the following:

$Excel = Win32::OLE->GetActiveObject('Excel.Application') || Win32::OL +E->new('Excel.Application', 'Quit'); $Book = $Excel->Workbooks->Open( $templateFile ); # #decoding code here # $Book->Worksheets($sheetNumber)->Range("A$Row:E$Row")->{Value} = [[$Ti +meAbs,$TimeRel,$TimeLog,$Info,$SigValue]];

The NYTProf output for the last line of code shows something like:

  "# spent 35.5s making 44688 calls to Win32::OLE::AUTOLOAD, avg 794µs/call"

and a few lines below:

  "# spent 454s making 22344 calls to Win32::OLE::DESTROY, avg 20.3ms/call"

What I want to understand is why the AUTOLOAD function is called here? (Moreover why it is called 2 times every time the line is passed(the line is called 22344 times). Could this be related to the fact that I use Win32::OLE on a configuration on 64bits (both Windows and Excel)? Also, why is the destructor so time expensive and why is it called every time the line is executed? I suppose that some temporary objects are created there but I do not have enough experience with Win32::OLE to figure it out.

Any suggestions, hints, tutorials are welcome. Thanks.

Sebi


In reply to Win32::OLE Excel temporary objects destruction by ndts

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.