What is the fastest way to compare two byte arrays?

后端 未结 6 1494
你的背包
你的背包 2021-01-18 07:59

I am trying to compare two long bytearrays in VB.NET and have run into a snag. Comparing two 50 megabyte files takes almost two minutes, so I\'m clearly doing something wron

6条回答
  •  执笔经年
    2021-01-18 08:24

    Not strictly related to the comparison algorithm:

    Are you sure your bottleneck is not related to the memory available and the time used to load the byte arrays? Loading two 2 GB byte arrays just to compare them could bring most machines to their knees. If the program design allows, try using streams to read smaller chunks instead.

提交回复
热议问题