-
Notifications
You must be signed in to change notification settings - Fork 107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
VerbalExpression Performance Question #18
Comments
I'm guessing the extra time is just due to the chaining of the methods calling individual expressions themselves instead of just one big expression like in the second test. Would be interesting to hear other thoughts, though. |
Changing to the following test brings almost the same results: [Test]
As I understand it the chaining gets translated to the same regular expression here:
So why the big time difference? |
Perhaps because it still has to chain it all together before it can get to the IsMatch() method that's taking the extra time? I might run it under the profiler when I get a chance and see if I can find anything. |
If i understand correctly , you are timing the amount of time it takes for a verbex to initialize and to be asserted versus a regex and i dont see the point here. If i were to benchmark performance for verbex vs regex then i would have them already initialized and run agains a very large search input ( a large text file) a couple of hundreds of times , and then obtain an average and compare the both. How does this sound? |
Same big gap (135ms to 1ms) in the following example:
And here it's the same regular expression. |
alexpeta: I'll try that, thanks. |
It's just the initialization of Regex the first time. Try doing the regex timing first and then the verbex and you get exactly the opposite result:
|
Hi, private const string urlListFilePath = @"Data\urlList.txt";
Tested average of 10 test runs and 20 and results are the same: regular expression takes about 250 ms while verbal expression takes 4000 ms. What do you thinks? |
Just to make the former post clearer, regular expression average run takes about 250 ms per run on 300K urls, while verbal expression takes about 4000 ms per run. Same results for 100 runs. |
I totally forgot to profile it the other night, but I'll remember to do so tonight to see what it looks like from that perspective. I like messing with performance stuff, so thanks for posing these questions! :] |
Let me know if I'm totally wrong with this, everyone. Did a small memory profile and it seems to indicate that the biggest offender may be the Test method. Looking at it, it calls the PatternRegex.IsMatch() method. The PatternRegex property seems to new up a new Regex object each time. I wonder if doing that each time it's called can cause it to create new objects on the heap each time it's called cause the performance numbers you were encountering? |
Interesting have to look into this... |
hello ? return Regex.IsMatch(toTest, RegexString, _modifiers); and Capture to this var match = Regex.Match(toTest, RegexString, _modifiers);` |
Hi all,
I ran the following test to check how well verbal expression performs compared to a regular expression:
I ran it a couple of times and verbal expression runs at about 130 milliseconds, while regular expression runs in about 5 ms.
Same results returned in other tests I did.
I'm considering using the verbal expression in my indexing project, so this time gap is too big.
What do you think?
Thanks
The text was updated successfully, but these errors were encountered: