ipaddressrange icon indicating copy to clipboard operation
ipaddressrange copied to clipboard

Parsing performance

Open yahorsi opened this issue 10 years ago • 3 comments

Hi, thanks for the great lib, the ONLY for the ranges!!! Really really useful.

The IP ranges mught be used on some really hot paths in the app, so, did you ever consider replacing Regex.Match with something more robust & fast?

yahorsi avatar Apr 09 '15 15:04 yahorsi

I feel it is good idea about improvement to more faster parsing IP range text, I agree.

But I don't have enough my resouce (my private time), and more important point, I have no skill to how to coding more faster parsing :sob:

Could you improve this issue and send me pull request? Or can you find anybody to improve this issue?

P.S. I have already Unit Test suite, so these refactoring can feel free to apply, and safety :)

jsakamoto avatar Apr 11 '15 12:04 jsakamoto

Regex is very fast, and the use of regex here I'd say is appropriate. It could be made slightly faster, in some cases, by declaring static regex properties rather than in-line parameters, but even as-is, the compiled regular expressions are cached. Good reference about this: [https://msdn.microsoft.com/en-us/library/gg578045%28v=vs.110%29.aspx](Best Practices for Regular Expressions in the .NET Framework).

Now, if you're suggesting something other than regex, my gut reaction is that it's the wrong way to go. There are a wide range of inputs, so anything that can handle all of them is going to be complex, and complex flow is hard to make robust.

That said, the way forward is to make a pull request and include some comparative benchmarks showing the improvement. :)

gregmac avatar Jun 03 '15 02:06 gregmac

for example, IPAddress class use native system calls for parsing IPs, but for quick googling dont tell me

  1. native method for network
  2. this solution is hard to implement and make cross-platform

llCorvinSll avatar Sep 27 '15 09:09 llCorvinSll