private String CollectDelays() { var result = ""; int count = Random.Next(4) + 1; int delay = 0; if (Tweaker.Lookup(hostname).ConsumeBandwith > 0) { int consumeBandwidthBps = Tweaker.Lookup(hostname).ConsumeBandwith; if (consumeBandwidthBps < Constants.MAX_BANDWIDTH_BPS * 0.7) { delay = 0; } else if (consumeBandwidthBps >= Constants.MAX_BANDWIDTH_BPS) { delay = 400 + Random.Next(300); } else { double modifier = (consumeBandwidthBps - Constants.MAX_BANDWIDTH_BPS * 0.7) / (Constants.MAX_BANDWIDTH_BPS * 0.3); delay = (int)(400 * modifier); } } int addLatency = Tweaker.Lookup(hostname).AddLatency; for (int i = 0; i <= count; i++) { result += (delay + Random.Next(70) + addLatency) + (i == count ? "" : ", "); } return(result); }
private String CollectPerformance() { int consumeCores = Tweaker.Lookup(hostname).ConsumeCores; if (consumeCores == Constants.NUM_CORES /*All cores */) { return((1 + Random.Next(4)).ToString()); } int candidate = 89 + Random.Next(12); if (consumeCores == 0) { return(candidate.ToString()); } double modifier = 1 - ((double)consumeCores / Constants.NUM_CORES); return(((int)(candidate * modifier)).ToString()); }