The Game Creators
The Game Creators Home Online Shop Click to Login
  Hot: Christmas CompetitionNovember NewsletterModel Pack 36DB Pro Pack 2009DGS BonanzaCharacter PackFPS Creator Bonanza;
The Game Creators
Programming Talk / Play Basic - VM2 String Engine in PB1.62

Go to the first page of this board Return to the Forum Menu Post Message
4 Messages - Page   of 1   
Bookmark and Share Search the Forum

Author Message
Kevin Picone

Valued Member


Joined: Tue Aug 27th 2002
Location: Australia
Posted: 2nd Jan 2007 22:04           | link | toggle

VM2 - String Engine Activated

I've just finished the main conversion from PB's string engine, with some spectacular results. (if i don't say so myself). Here's the current benchmark results between PB1.61 + PB1.62 running the code bellow.

The test is running on AMD 3000 system. The results are the average time over 200 frames. Each test is 25000 loops, working on75 to 100 Chr strings in most operations. You do the math, that's a tanker load of data !


PB1.61

Quote: "
Assignment = 4.04
Left & Right$ = 69.98
Instring = 182.612
Replace = 6723.07
Total Time = 1403.31 seconds
"

Yes, It took 23 and 1/2 minutes to run this test in PB1.61.. (1403/60 )



PB1.62

Quote: "
Assignment = 7.14
Left & Right$ = 17.27
Instring = 34.33
Replace = 75.20
Total Time = 27.37 seconds
"

The new engine is a bit slower during direct assignments though. I can probably enhance that, but I think it may well be due to the multi string format design. (IE's that's bit of overhead in a copy now) In other words, we'll loose a little in one area, but gain a lot in others. So it's not an issue worth worrying too much about !

+ Code Snippet


	Dim Results#(100)


	Max=25000
TestStart=timer()

	repeat
		cls 0

			inc frames
			test=1
			print "Current Frame:"+str$(frames)


			; =====================================================================
			ts=timer()

				for lp=0 to max
					a$="AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
					b$=a$
				next
			t=Timer()-ts
		
			Results#(test)=results#(test)+t
			Print "    String Assignment:"+Str$(results#(test)/frames)
			test=test+1


	
			; =====================================================================
			ts=timer()
				a$="0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789"
				MidChr=len(a$)/2
				for lp=0 to max
					b$=left$(a$,MidChr)
					b$=Right$(a$,MidCHr)
				next
			t=Timer()-ts
		
			Results#(test)=results#(test)+t
			Print "  String Left$/RIGHT$:"+Str$(results#(test)/frames)
			test=test+1



			; =====================================================================
			TestString$		="01234567890123456789012345678901234567890123456789"
			TestString$		=TestString$+TestString$+"World"
			
			FindString$			="World"

			ts=timer()
				for lp=0 to max
					Pos=Instring(TEststring$,FIndString$,0,false)
					Pos=Instring(TEststring$,FIndString$,0,true)
				next
			t=Timer()-ts
		
			Results#(test)=results#(test)+t
			Print "             Instring:"+Str$(results#(test)/frames)
			test=test+1







			; =====================================================================
			; =====================================================================

			TestString$="01234567890123456789012345678901234567890123456789"
			TestString$=TestString$+TestString$
			
			FindString$="01234"
			ReplaceString$="<<<<<<<<<<01234>>>>>>>>>>"

;			print TestString$
			Lowercase=false


			ts=timer()
				for lp=0 to max
;					Pos=Instring(TEststring$,FIndString$,0,false)
;					Pos=Instring(TEststring$,FIndString$,0,true)

					Dead1$=Replace$(TestString$,FindString$,ReplaceString$,0,Lowercase,false)
					Dead2$=Replace$(TestString$,FindString$,ReplaceString$,0,Lowercase,true)


				next

			t=Timer()-ts
			Results#(test)=results#(test)+t
			Print "              Replace:"+Str$(results#(test)/frames)
			test=test+1

;			print str$(len(dead1$))+"  "+dead1$
;			print str$(len(dead2$))+"  "+dead2$
	
		sync

Until Frames>200

Print "Test Complete"
testEnd=Timer()-TestSTart
Print "Seconds:"+Str$((Timer()-TestStart)/1000.0)
Sync
WaitKey





Older Thread on the subject

Back to top
Underware Design
Report this message as abusive
Jeku

Moderator


Joined: Fri Jul 4th 2003
Location: Vancouver, Canada
Posted: 4th Jan 2007 01:17           | link | toggle

Wow, that is awesome! PB is really shaping up to be serious contender, if it's not already

Back to top
Automaton Games
Report this message as abusive
Google Ad
Back to top
 
Kevin Picone

Valued Member


Joined: Tue Aug 27th 2002
Location: Australia
Posted: 5th Jan 2007 18:42           | link | toggle
Back to top
Underware Design
Report this message as abusive
Kevin Picone

Valued Member


Joined: Tue Aug 27th 2002
Location: Australia
Posted: 7th Jan 2007 06:38           | link | toggle

SplitToArray

SplitToArray() is one those very useful commands people seem to forget. While useful, I was never that happy with it's implementation behind the scenes. So today I've been totally rewriting to avoid memory thrashing with the new string engine, the results bellow speak for themselves. And there's room for improvement.

Just in case you're unsure SplitToArray() allows the programmer to convert a delimited string into Integer, float or String array in one hit.


Results for SplitToArray test (25000 calls, each call Splits string of 20 delimited string integers to an Integer array)

PB1.61 = 7150 (ish) milliseconds
PB1.62b = 153 milliseconds

+ Code Snippet
			; =====================================================================
			; =====================================================================

			s$="1234567,2,300033,4,5,6,7,888,999-10,11,12,13,14,15,16,17,18,19,20"
			d$=" ,-"	
			ts=timer()
				for lp=0 to max
					Count=SplitToArray(s$,d$,Integers(),0)
				next

			t=Timer()-ts
			Results#(test)=results#(test)+t
			Print "        Split To Array:"+Str$(results#(test)/frames)
			test=test+1



Back to top
Underware Design
Report this message as abusive

Go to the first page of this board Return to the Forum Menu Post Message
4 Messages - Page   of 1   
Search the Forum

Sorry, but it has been so long since anyone replied to this Thread that it has been automatically locked.
You may read it but not reply.

Forum Search

Enter a word or phrase to search our Forum for:

Thread Subject Search
Search Phrase:
Search Scope: Entire forum
Just this board
 
Google Forum Search
Search Phrase:
 
Apollo v2.02


Dark Game Studio
Privacy Policy AUP Top of Page