public PrimitiveEventGenerator[] getGeneratorsFromRateString(string rateString) { string names = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; int i = 0; var data = new PrimitiveEventGenerator[rateString.Split(" ").Count()]; foreach (var rate in rateString.Split(" ")) { data[i] = new PrimitiveEventGenerator(Int16.Parse(rate), TimeUnit.Second, new EventType(names[i].ToString())); i++; } return(data); }
public void test_low_rate_in_range() { var seconds = 2; var eventsPerInterval = 1; var g = new PrimitiveEventGenerator(eventsPerInterval, TimeUnit.Second, new EventType("T")); var sw = new Stopwatch(); long count = 0; sw.Start(); while (sw.ElapsedMilliseconds < seconds * 1000) { count += g.generate().Length; } Assert.InRange(count / (float)(seconds * eventsPerInterval), 0.999, 1.001); }
public void test_shorter_duration_fewer_events() { var seconds = 2; var eventsPerInterval = 100000; var g = new PrimitiveEventGenerator(eventsPerInterval, TimeUnit.Second, new EventType("T")); var sw = new Stopwatch(); long count = 0; sw.Start(); while (sw.ElapsedMilliseconds < (seconds - 1) * 1000) { count += g.generate().Length; } var actualratio = count / (float)(seconds * eventsPerInterval); Assert.NotInRange(actualratio, 0.999, 1.001); Assert.True(actualratio < 1.0); }