Click here to Skip to main content
15,941,615 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
GeneralRe: Ethics for WFH Pin
MarkTJohnson11-Jan-24 6:35
professionalMarkTJohnson11-Jan-24 6:35 
GeneralRe: Ethics for WFH Pin
TNCaver11-Jan-24 16:07
TNCaver11-Jan-24 16:07 
GeneralRe: Ethics for WFH Pin
rnbergren15-Jan-24 5:13
rnbergren15-Jan-24 5:13 
GeneralRe: Ethics for WFH Pin
Matthew Dennis11-Jan-24 4:37
sysadminMatthew Dennis11-Jan-24 4:37 
GeneralXKCD fans: Randal has a channel now. PinPopular
OriginalGriff11-Jan-24 2:22
mveOriginalGriff11-Jan-24 2:22 
GeneralRe: XKCD fans: Randal has a channel now. Pin
BernardIE531711-Jan-24 3:15
BernardIE531711-Jan-24 3:15 
GeneralRe: XKCD fans: Randal has a channel now. Pin
BernardIE531713-Jan-24 22:08
BernardIE531713-Jan-24 22:08 
GeneralI have begun the long slow journey to redemption. Pin
honey the codewitch11-Jan-24 2:04
mvahoney the codewitch11-Jan-24 2:04 
My Visual FA project was a bust, with broken benchmarks and too slow code.

I know in theory a DFA regex can beat one that backtracks, but Microsoft has done a damned good job of optimizing their engine in recent years.

My issue is they're using ReadOnlySpan<char> over the input string so if I want to beat it I have to use that as well.

That won't stream, but I can generate separate code for that.

Here's my result so far

Microsoft Regex compiled "Lexer": Found 170000 matches in 13ms
FAStringRunner: Found 170000 matches in 10ms

I can probably make it a little faster still.

The FAStringRunner was created by hand, by me, not generated by a regular expression.

It looks like this

C#
q1:
if (((((ch >= 9)
			&& (ch <= 10))
			|| (ch == 13))
			|| (ch == 32)))
{
	++len;
	if (position < span.Length - 1)
	{
		ch = span[unchecked((int)++position)];
	}
	else
	{
		ch = '\0';
	}
	goto q1;
}
return FAMatch.Create(2, span.Slice(unchecked((int)p), len).ToString(), p, l, c);
q2:
if (((ch >= 49)
			&& (ch <= 57)))
{
	++len;
	if (position < span.Length - 1)
	{
		ch = span[unchecked((int)++position)];
	}
	else
	{
		ch = '\0';
	}
	goto q3;
}
goto errorout;



I wrote this by hand because I needed to test to see if I could match faster than Microsoft before I wrote any generator code to do so.

I've got a lot of code to write.

Edit: Okay they're really challenging me here:

Terminal
Microsoft Regex compiled "Lexer":  Found 1440000 matches in 91ms
FAStringRunner:  Found 1430000 matches in 81ms
Microsoft Regex compiled "Lexer":  Found 1440000 matches in 89ms
FAStringRunner:  Found 1430000 matches in 80ms
Microsoft Regex compiled "Lexer":  Found 1440000 matches in 80ms
FAStringRunner:  Found 1430000 matches in 80ms
Microsoft Regex compiled "Lexer":  Found 1440000 matches in 70ms
FAStringRunner:  Found 1430000 matches in 80ms
Microsoft Regex compiled "Lexer":  Found 1440000 matches in 71ms
FAStringRunner:  Found 1430000 matches in 80ms
Microsoft Regex compiled "Lexer":  Found 1440000 matches in 71ms
FAStringRunner:  Found 1430000 matches in 81ms
Microsoft Regex compiled "Lexer":  Found 1440000 matches in 71ms
FAStringRunner:  Found 1430000 matches in 80ms
Microsoft Regex compiled "Lexer":  Found 1440000 matches in 73ms
FAStringRunner:  Found 1430000 matches in 79ms
Microsoft Regex compiled "Lexer":  Found 1440000 matches in 72ms
FAStringRunner:  Found 1430000 matches in 80ms
Microsoft Regex compiled "Lexer":  Found 1440000 matches in 69ms
FAStringRunner:  Found 1430000 matches in 79ms


Edit 2: NVM I was in debug mode

Terminal
Microsoft Regex compiled "Lexer":  Found 1440000 matches in 88ms
FAStringRunner:  Found 1430000 matches in 24ms
Microsoft Regex compiled "Lexer":  Found 1440000 matches in 84ms
FAStringRunner:  Found 1430000 matches in 22ms
Microsoft Regex compiled "Lexer":  Found 1440000 matches in 81ms
FAStringRunner:  Found 1430000 matches in 22ms
Microsoft Regex compiled "Lexer":  Found 1440000 matches in 70ms
FAStringRunner:  Found 1430000 matches in 21ms
Microsoft Regex compiled "Lexer":  Found 1440000 matches in 69ms
FAStringRunner:  Found 1430000 matches in 22ms
Microsoft Regex compiled "Lexer":  Found 1440000 matches in 69ms
FAStringRunner:  Found 1430000 matches in 21ms
Microsoft Regex compiled "Lexer":  Found 1440000 matches in 69ms
FAStringRunner:  Found 1430000 matches in 22ms
Microsoft Regex compiled "Lexer":  Found 1440000 matches in 69ms
FAStringRunner:  Found 1430000 matches in 22ms
Microsoft Regex compiled "Lexer":  Found 1440000 matches in 69ms
FAStringRunner:  Found 1430000 matches in 22ms
Microsoft Regex compiled "Lexer":  Found 1440000 matches in 71ms
FAStringRunner:  Found 1430000 matches in 22ms


Better
Check out my IoT graphics library here:
https://honeythecodewitch.com/gfx
And my IoT UI/User Experience library here:
https://honeythecodewitch.com/uix


modified 11-Jan-24 9:29am.

GeneralRe: I have begun the long slow journey to redemption. Pin
englebart11-Jan-24 6:57
professionalenglebart11-Jan-24 6:57 
GeneralRe: I have begun the long slow journey to redemption. Pin
honey the codewitch11-Jan-24 6:59
mvahoney the codewitch11-Jan-24 6:59 
GeneralRe: I have begun the long slow journey to redemption. Pin
Paul612411-Jan-24 11:41
Paul612411-Jan-24 11:41 
GeneralRe: I have begun the long slow journey to redemption. Pin
honey the codewitch11-Jan-24 11:50
mvahoney the codewitch11-Jan-24 11:50 
GeneralRe: I have begun the long slow journey to redemption. Pin
BernardIE531713-Jan-24 22:33
BernardIE531713-Jan-24 22:33 
GeneralRe: I have begun the long slow journey to redemption. Pin
BernardIE531713-Jan-24 22:26
BernardIE531713-Jan-24 22:26 
GeneralRe: I have begun the long slow journey to redemption. Pin
honey the codewitch13-Jan-24 22:28
mvahoney the codewitch13-Jan-24 22:28 
GeneralCode Project Issues? Pin
glennPattonWork310-Jan-24 23:17
professionalglennPattonWork310-Jan-24 23:17 
GeneralRe: Code Project Issues? Pin
David O'Neil10-Jan-24 23:48
professionalDavid O'Neil10-Jan-24 23:48 
GeneralRe: Code Project Issues? Pin
glennPattonWork310-Jan-24 23:49
professionalglennPattonWork310-Jan-24 23:49 
GeneralRe: Code Project Issues? Pin
Richard MacCutchan11-Jan-24 0:09
mveRichard MacCutchan11-Jan-24 0:09 
GeneralRe: Code Project Issues? Pin
David O'Neil11-Jan-24 0:45
professionalDavid O'Neil11-Jan-24 0:45 
GeneralRe: Code Project Issues? Pin
Chris Maunder11-Jan-24 1:23
cofounderChris Maunder11-Jan-24 1:23 
GeneralRe: Code Project Issues? Pin
Richard MacCutchan11-Jan-24 2:48
mveRichard MacCutchan11-Jan-24 2:48 
GeneralRe: Code Project Issues? Pin
MarkTJohnson11-Jan-24 3:25
professionalMarkTJohnson11-Jan-24 3:25 
GeneralRe: Code Project Issues? Pin
glennPattonWork311-Jan-24 3:42
professionalglennPattonWork311-Jan-24 3:42 
GeneralRe: Code Project Issues? Pin
dandy7211-Jan-24 3:45
dandy7211-Jan-24 3:45 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.