阅读背景:

在byte []中查找byte []和在string中查找字符串的速度 - 为什么后者更快?

来源:互联网 

I have a task where I need to look up for sequences in a file. When doing a test application, I have read file as string (File.ReadAllText) and used string.IndexOf to look up for a sequence. When I tried to implement the same algorithm with bytes (reading file as byte array and looking up byte array in byte array), I noticed that looking for byte[] in byte[] is about 3 times as slow as looking for string in string. I made sure to check it throughly, and exactly the same code, one using byte[] and other using string, take 3 times as much to execute - like, 16s for byte vs ~5s for string.I have a task where I need to look up for seque




你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: