Gamestudio Links
Zorro Links
Newest Posts
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
Trading Journey
by howardR. 04/28/24 09:55
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
Why Zorro supports up to 72 cores?
by jcl. 04/26/24 11:09
Eigenwerbung
by jcl. 04/26/24 11:08
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (Quad, degenerate_762), 642 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
wandaluciaia, Mega_Rod, EternallyCurious, howardR, 11honza11
19049 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
str_stri surcharge #449033
02/28/15 11:53
02/28/15 11:53
Joined: Jun 2007
Posts: 1,337
Hiporope and its pain
txesmi Offline OP
Serious User
txesmi  Offline OP
Serious User

Joined: Jun 2007
Posts: 1,337
Hiporope and its pain
Hi,
I needed to intensively use str_stri for a osm hypertext parser I am writing and I realized that it got slower the bigger the parsed strings or char buffers were. In the try of indetifying the problem I substituted all the str_stri calls by my own function and surprisingly it solved the problem. I could not believe it.

Click to reveal..

Code:
var str_stri_custom ( char *chr1, char *chr2 )
{
	var pos = 0;
	while ( *chr1 != NULL )
	{
		pos += 1;
		if ( *chr1 == *chr2 )
		{
			char *chr1b = chr1 + 1;
			char *chr2b = chr2 + 1;
			while ( ( *chr1b != NULL ) && ( *chr2b != NULL ) )
			{
				if ( *chr1b != *chr2b )
					break;
				chr1b += 1;
				chr2b += 1;
			}
			if ( *chr2b == NULL )
				return pos;
		}
		chr1 += 1;
	}
	return 0;
}



Re: str_stri surcharge [Re: txesmi] #449047
03/02/15 11:01
03/02/15 11:01
Joined: Sep 2003
Posts: 9,859
F
FBL Offline
Senior Expert
FBL  Offline
Senior Expert
F

Joined: Sep 2003
Posts: 9,859
Did you also try in published mode?

I don't know the engine code - but for sure there's a certain chance that in development mode there are debug routines active for detecting array out of bounds and the like.

Re: str_stri surcharge [Re: FBL] #449050
03/02/15 14:39
03/02/15 14:39
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
There is some overhead in development mode, but it should not make much difference. str_stri is in fact very slow, as far as I can see in the source code. Your function is much faster. I don't see at a first glance why str_stri is coded this way, maybe it's due to some special case handling. As long as you don't use unicode or some STRING specific stuff I recommend that you continue with your own function.

Re: str_stri surcharge [Re: jcl] #449078
03/03/15 12:28
03/03/15 12:28
Joined: Jun 2007
Posts: 1,337
Hiporope and its pain
txesmi Offline OP
Serious User
txesmi  Offline OP
Serious User

Joined: Jun 2007
Posts: 1,337
Hiporope and its pain
Thank you for your answers!
I will go this way. Maybe a chr_cmp is a good choice too.

Salud!


Moderated by  jcl, Nems, Spirit, Tobias 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1