/// <summary> /// This method will prime the simulator with known-popular passwords so that they are treated /// as if the simulator had already observed them (or been configured with them) /// </summary> /// <returns></returns> public void PrimeWithKnownPasswordsAsync(BinomialLadderFilter freqFilter, int numberOfTimesToPrime) { for (int i = 0; i < numberOfTimesToPrime; i++) { Parallel.ForEach(_passwordsAlreadyKnownToBePopular, (password) => freqFilter.Step(password)); } }
public void TwentyObservations() { BinomialLadderFilter freqFilter = new BinomialLadderFilter(1024 * 1024 * 1024, 64); string somethingToObserve = "Gosh. It's a nice day out, isn't it?"; int observationCount = freqFilter.GetHeight(somethingToObserve); for (int i = 0; i < 25; i++) { int lastCount = freqFilter.Step(somethingToObserve); Assert.Equal(observationCount, lastCount); observationCount++; } Assert.Equal(observationCount, freqFilter.GetHeight(somethingToObserve)); }