what is the fastest way to generate a unique set in .net 2

前端 未结 6 820
离开以前
离开以前 2021-01-12 21:46

I have what is essentially a jagged array of name value pairs - i need to generate a set of unique name values from this. the jagged array is approx 86,000 x 11 values. It d

6条回答
  •  梦谈多话
    2021-01-12 22:13

    Have you profiled your code? You are certain that the foreach loops are the bottleneck, and not retriever.GetVehicles()?

    I did create a small test project where I fake the retriever and let it return 86.000 X 11 values. My first attempt ran at 5 seconds, creating the data included.

    I used the same value for both the key and value where the first key was "0#0" and the last "85999#10".

    Then I switched to guids. Same result.

    Then I made the key longer, like this:

            var s = Guid.NewGuid().ToString();
            return s + s + s + s + s + s + s+ s + s + s;
    

    Now it took almost 10 seconds.

    Then I made the keys insanely long and got an out of memory exception. I don't have a swap file on my computer, so I got this exception immediately.

    How long are your keys? Are your virtual memory consumption the reason for your poor performance?

提交回复
热议问题