public void ContainsTest() { const Int32 count = 1000000; // generate ip var ipArray = new UInt32[count]; for (var index = 0; index < count; index++) { ipArray[index] = (UInt32)random.Next(); } var resultArray = new Boolean[count]; var testResult = LoadTest.Execute ( "ContainsTest", index => { var ipAddress = ipArray[index]; resultArray[index] = geolocationTree.Contains(ipAddress); }, count ); Trace.WriteLine(testResult.ToString()); Trace.TraceInformation("Result is {0} hits and {1} misses", resultArray.Count(x => x), resultArray.Count(x => x == false)); }
public void TryGetValue() { const Int32 Count = 1000000; // generate ip var ipArray = new UInt32[Count]; for (var index = 0; index < Count; index++) { ipArray[index] = (UInt32)random.Next(Int32.MinValue, Int32.MaxValue); } var hitCount = 0; var missCount = 0; var testResult = LoadTest.Execute ( "ContainsTest", index => { var ipAddress = ipArray[index]; if (geolocationTree.TryGetValue(ipAddress).Success) { hitCount++; } else { missCount++; } }, Count ); Trace.WriteLine(testResult.ToString()); Trace.TraceInformation("Result is {0} hits and {1} misses", hitCount, missCount); }