Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

Plugin question

May
13,199
180
I wrote a little EXE to do a version of "TYPE /X". This loop is at its heart:

while ( ReadFile(hFileIn, buf, 16, &dwRead, NULL) && dwRead )
{
Printf(L"%08.8X ", 16 * dwCount++);

for ( i=0; i<dwread; i++="" )="">
Printf(L"%02.2X ", buf);

dwPad = 49 - 3 * dwRead;
wsprintf(szFormat, L"%%%lu.%lus", dwPad, dwPad);
Printf(szFormat, L"");

for ( i=0; i<dwread; i++="" )="">
{
if ( buf > 31 && buf < 128 )
Printf(L"%c", buf);
else
Printf(L".");
}

Printf(L"\r\n");
}
<dwread; i++="" )=""><dwread; i++="" )=""><dwread; i++="" )=""><dwread; i++="" )="">

<dwread; i++="" )=""><dwread; i++="" )="">When I use TCC to run the EXE on EXPLORER.EXE (1.1MB) and redirect the output to a file, it takes about 1/2 sec. When I make that routine into a plugin function (only change needed is wprintf() to Printf()) the same task takes about 40 sec. Why the big difference? I've never seen that with other plugin functions I've written. I figure I've got something wrong.

Notice how pasting the code into vBulletin, even with CODE tags removes characters from my "for" statements! Buth should also contain: i (less) dwRead; i++ ).

</dwread;></dwread;></dwread;></dwread;></dwread;></dwread;></dwread;></dwread;>
 
vefatica wrote:
...
| Notice how pasting the code into vBulletin, even with CODE tags
| removes characters from my "for" statements! Buth should also
| contain: i (less) dwRead; i++ ).

... and when delivered as email, the code is totally unreadable.
--
Steve
 
> vefatica wrote:
> When I make that routine into a plugin function (only change needed is wprintf() to Printf())
> the same task takes about 40 sec.

I've seen funny behavior especially when 0x07 is included. Try making
a large ASCII file and see if the time still is much different.

This generates about the same file size if test.txt doesn't exist initially.
for /l %i in (1,1,14000) do echo %@repeat[a,80] >> test.txt

On Mon, Mar 16, 2009 at 7:44 AM, Steve Fábián <> wrote:

> vefatica wrote:
> ...
> | Notice how pasting the code into vBulletin, even with CODE tags


> ... and when delivered as email, the code is totally unreadable.

Huh. In my email reader (Gmail), the code itself was rendered must
better than "totally unreadable". It did append after each for (;;)
loop the characters equal quote quote greater and in some places an
equal quote quote. I believe all the line breaks and indenting were
retained. Reading the same email on my iPhone's built-in email
inserted artificial line breaks due to screen size, but was otherwise
the same.




--
Jim Cook
2009 Saturdays: 4/4, 6/6, 8/8, 10/10, 12/12 and 5/9, 9/5, 7/11, 11/7.
Next year they're Sunday.
 
:: I've seen funny behavior especially when 0x07 is included. Try making
:: a large ASCII file and see if the time still is much different.

0x07 doesn't matter here; I'm not trying to print it. I'm pretty sure the speed of the EXE and the slowness of the plugin have to do with the buffering of output (which wprintf does). I was calling TCC's Printf to write a few (even one) characters at a time (34 Printf's per line!). When I constructed the whole line before outputting it (33 wsprintf's and 1 Printf) I cut that 40 seconds to 1.5 seconds.
 
Back
Top
[FOX] Ultimate Translator
Translate