:) hey All,

got a chance to re-look at my PBIndexIt code,
and Thanks to F0dder's and Death's help, I made a few improvements if anyone is interested:

PBIndexIt2

a command-line indexer, my 300 mhz P2 running '98

the original:
indexes my win32api.inc of 103813 words in about .32 secs..

this version:
indexes my win32api.inc of 103813 words in about .04887 secs..

(note: I moved Query Performance Counter to just before the loop, to match Death's C++ example)
also: no criticism intended, but just for comparison
Death's C++ exe is 100k, this one is 16k...

exe is here: http://www.sweetheartgames.com/testcode/PBIndexIt2.exe



#COMPILE EXE

DECLARE FUNCTION QueryPerformanceCounter LIB "KERNEL32.DLL" ALIAS "QueryPerformanceCounter" _
(lpPerformanceCount AS QUAD) AS LONG
DECLARE FUNCTION QueryPerformanceFrequency LIB "KERNEL32.DLL" ALIAS "QueryPerformanceFrequency" _
(lpFrequency AS QUAD) AS LONG

FUNCTION PBMAIN ()
DIM C1 AS QUAD,C2 AS QUAD , F1 AS QUAD
DIM txt AS STRING, i AS LONG, n AS LONG
DIM pb AS BYTE POINTER

IF GETATTR(COMMAND$)=32 then

OPEN TRIM$(COMMAND$) FOR BINARY AS 1
GET$ #1, LOF(1), txt
CLOSE 1
pb = STRPTR(txt)
DIM w(LEN(txt)) AS ASCIIZ POINTER
QueryPerformanceCounter C1

FOR i = 0 TO LEN(txt)
if @pb[i]=32 THEN GOTO WhiteSpace
if @pb[i]=10 THEN GOTO WhiteSpace
if @pb[i]=13 THEN GOTO WhiteSpace
WantChar:
NEXT
QueryPerformanceCounter C2
REDIM PRESERVE w(n)
!Jmp zExit
WhiteSpace: 'skip null Char's
@pb[i]=0
INCR i
if @pb[i]=32 THEN GOTO WhiteSpace
if @pb[i]=10 THEN GOTO WhiteSpace
if @pb[i]=13 THEN GOTO WhiteSpace
NewWord: 'set index ptr
INCR n
w(n) = pb + i
!Jmp WantChar
zExit:
QueryPerformanceFrequency F1
MSGBOX "On a 300mhz P2 running '98" _
+ $CRLF + "Indexed " + FORMAT$(UBOUND(w())) + " words in " + FORMAT$((C2-C1)/F1)+ " secs " _
+ $CRLF + "size of txt is " + FORMAT$(LEN(txt))

else
msgbox "File not found" _
+ $CRLF + "Ex. Usage from RUN:" _
+ $CRLF + "C:\PBIndexIt.exe c:\winapi\win32api.inc"
EXIT FUNCTION
end if
END FUNCTION
Posted on 2004-04-24 17:39:32 by Brad Byrne
Brad, this version still contains bugs. I suggest you read the comments in my source code and fix them.
Posted on 2004-04-24 18:02:07 by death
:) yeah that's true Death, forgot about them.. I'll fix in a while

Thx

also: before this turns into another PB/C bashing thread..
It does seem evident to me that VC's optimizer is very good... first I wish to use the the differance/s to finish learning PB... then C++.. Thanks
Posted on 2004-04-24 18:07:31 by Brad Byrne
If you didn't want it to turn into a bashing thread then you probably should have put it in The Heap where it belongs in the first place.

kthxbye
Posted on 2004-04-24 18:56:56 by iblis
It appears my version had a bug as well. I included the zero byte in the loop, and it's not a whitespace, so my version added it as the last word. Here I post the corrected version, with another little speed optimization.

I also made another version, which takes size into consideration. I used the WCRT library by Jibz and FloatToStr() by Tim Roberts. The resulting executable runs as fast as test.exe and test2.exe, and its size is 4kb.

The results:

test2.exe (100kb): Indexed 754933 words in 0.0976674 secs. File size is 5529074
test3.exe (4kb): Indexed 754933 words in 0.1032008 secs, File size 5529074

(By the way, the file I'm using for the tests is Ralf Brown's Interrupt List's INTERRUP.LST)


Oh, and your PBIndexIt2.exe (16kb): Indexed 754933 words in .160132921921641 secs


PS.. this was a 15 min. hackjob. I did it after half an hour of non-sleep because I couldn't get the bug of my head. So now the bug is fixed, the hackjob's done, and I'm off to sleep.
Posted on 2004-04-24 20:05:39 by death
;) Thanks Much!! Death,

lot's of good info in that zip :)

Brad
Posted on 2004-04-24 20:22:03 by Brad Byrne
Brad,

I should have mentioned it before but if you want to look at a really classy C programming package, have a look at Pelle's C. Very well written IDE with a good dialog editor. Pelle wrote his own high performance linker and library manager which he has allowed to be used in MASM32 and his IDE also supports MASM so if you get the swing of it, you can do some very smart stuff.

Regards,
http://www.asmcommunity.net/board/cryptmail.php?tauntspiders=in.your.face@nomail.for.you&id=2f46ed9f24413347f14439b64bdc03fd
Posted on 2004-04-24 23:45:46 by hutch--
Hey Hutch,

I was looking at your Frequency code, and I know this is a dumb question..
but how do I declare lpArr if I want to use your code inline?..

ie.
SUB bfcounter(a$, BYVAL lpArr AS DWORD)

yeah, also, I got Pelle's code on me wish-list too...
PB first :)

Thanks
Brad
Posted on 2004-04-25 00:15:12 by Brad Byrne
Pelle's C is quite fine, but C only (no C++) and doesn't have as good an optimizer as VC++. But it might be worth a look, and perhaps the compiler from vctoolkit could be integrated with the IDE? http://www.smorgasbordet.com/
Posted on 2004-04-25 08:09:46 by f0dder