on a 30 page paper results in a processing rate of 0.158 sec/word, or about 379 words per minute on a P4 3.4 ghz with many gigs of memory. Now I know OLE is a dog, but that's about human reading speed! Clearly something is wrong.use strict; use Win32::OLE; use Win32::OLE::Const 'Microsoft Word'; my $filename = 'C:\temp\test.doc'; my $word = Win32::OLE->new('Word.Application', 'Quit'); my $doc = $word->Documents->Open($filename) || die("Unable to open doc +ument ", Win32::OLE->LastError()); my $nwords = $doc->Words->Count; my @wordtext; my @wordcolor; my $starttime = time; for(my $i = 1; $i <= $nwords; $i++) { $wordcolor[$i] = $doc->Words->Item($i)->HighlightColorIndex; $wordtext[$i] = $doc->Words->Item($i)->Text; } my $elapsed = time - $starttime; printf "\n\n%6.0D words\n%6.0D sec\n%5.3f per word", $nwords, $elapsed +, $elapsed/$nwords; $doc->Close; undef $word;
The stranger thing is that I did some experimenting, and the words-per-second rate is a linear function of the number of words in the document. In other words, the reading rate is twice as fast for a document half the size, twice as slow for a document twice the size, and so on. This one really baffles me bc I can't imagine why the size of the document would influence the reading speed unless it has to count from the beginning every time you request a word, and surely they didn't design the method like that.
So I checked the archives and found this thread about Word slowness and tried some of the suggested fixes. Disbling the Word macro checker and diabling the DEP helped maybe a little but didn't solve the problem.
Anybody know how I can speed this thing up? Can I get the text and color info in larger chunks, maybe?
Many thanks....
Steve
In reply to Win32 Word behaving strangely by cormanaz
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |