I noticed something when trying out the benchmarking feature today. It didn't seem to be any slower when matching ten results vs just one. So I knew something was up.
After looking into it I still can't fully explain what was happening. Perhaps there was some lazy loading going on, I'm not sure.
But I reworked the code today and it seems to scale properly now. It will slow down with more complex regular expressions, as well as target strings with more matches.
For those who are curious about how I'm performing the benchmarking now, here's the code:
I'm not sure how many of you use the benchmarking feature but I hope this sudden change doesn't mess anyone up.
After looking into it I still can't fully explain what was happening. Perhaps there was some lazy loading going on, I'm not sure.
But I reworked the code today and it seems to scale properly now. It will slow down with more complex regular expressions, as well as target strings with more matches.
For those who are curious about how I'm performing the benchmarking now, here's the code:
Dim startTime As DateTime = Date.Now Dim _regexBenchmark As New Regex(strRegex, _regexOptions) For i As Integer = 0 To iBenchmarkIterations For Each _match As Match In _regexBenchmark.Matches(strTargetString) If _match.Success Then ' Do nothing End If Next If Benchmarking.CancellationPending Then e.Cancel = True Exit For End If Next e.Result = Date.Now.Subtract(startTime).TotalMilliseconds
I'm not sure how many of you use the benchmarking feature but I hope this sudden change doesn't mess anyone up.
Comments
Post a Comment