SoWarum ist meine ElapsedMilliseconds hier immer Null?
Stopwatch Watch = new Stopwatch();
long tList = 0, tHset = 0; // ms
foreach (string Str in Copy)
{
// measure time to look up string in ordinary list
Watch.Start();
if (ListVersion.Contains(Str)) { }
Watch.Stop();
tList += Watch.ElapsedMilliseconds;
// now measure time to look up same string in my hash set
Watch.Reset();
Watch.Start();
if (this.Contains(Str)) { }
Watch.Stop();
tHset += Watch.ElapsedMilliseconds;
Watch.Reset();
}
int n = Copy.Count;
Console.WriteLine("Average milliseconds to look up in List: {0}", tList/n);
Console.WriteLine("Average milliseconds to look up in hashset: {0}", tHset/n);
es outputing 0
sowohl im Vergleich zu der Leistung der gleichen Elemente in einem List
und im folgenden Code-Block erstellt Ich versuche, um die Leistung des Hash-Sets zu messen ich. Irgendeine Idee warum das ist? Relevante Dokumentation: https://msdn.microsoft.com/en-us/library/system.diagnostics.stopwatch(v=vs.110).aspx
haben Die Vorgänge sind zu schnell und Sie sollten die Leistung nicht so messen. –