/// <summary> /// </summary> public WPFXamlDefinition(int maxTotalElements, int maxAttributes, int maxChildren, int maxDepth) { Initialize(DefaultRandomGenerator.GetGlobalRandomGenerator(), maxTotalElements, maxAttributes, maxChildren, maxDepth); }
/// <summary> /// </summary> internal Type GetRandomObject(Type baseType) { if (!IsLibraryCreated) { return(null); } int index; if (baseType != typeof(object)) { List <Type> types = new List <Type>(_types.Length); foreach (Type type in _types) { if (baseType.IsAssignableFrom(type)) { types.Add(type); } } if (types.Count == 0) { return(null); } index = DefaultRandomGenerator.GetGlobalRandomGenerator().Next(types.Count); return(types[index]); } index = DefaultRandomGenerator.GetGlobalRandomGenerator().Next(_types.Length); return(_types[index]); }
/// <summary> /// </summary> internal string GetRandomBamlFile() { if (!IsLibraryCreated) { return(null); } if (_bamlFiles == null) { lock (_instanceLock) { if (_bamlFiles == null) { _bamlFiles = Directory.GetFiles(_buildPath, "*.baml", SearchOption.AllDirectories); } } } string bamlFile = _bamlFiles[DefaultRandomGenerator.GetGlobalRandomGenerator().Next(_bamlFiles.Length)]; return(bamlFile); }
/// <summary> /// /// </summary> /// <param name="max"></param> /// <returns></returns> static int GetRandomNumber(int max) { return(DefaultRandomGenerator.GetGlobalRandomGenerator().Next(max)); }
/// <summary> /// </summary> public WPFXamlDefinition() : this(DefaultRandomGenerator.GetGlobalRandomGenerator()) { }
/// <summary> /// Returns whether or not an action should throttle its behavior. /// </summary> /// <param name="numerator"> /// Controls the probability of throttling as a fraction of the denominator. /// </param> /// <param name="denominator"> /// Controls the probability of throttling. /// </param> /// <remarks> /// Actions often need to tune their behavior in order to prevent /// breaking the constraints of the overall stress app. For example, /// an action that grows the size of a tree might need to prune the tree /// periodically in order to avoid using excessive memory for a long time. /// /// ShouldThrottle provides a simple mechanism for actions to make choices /// based on simple probabilites. For example, the action that grows a tree /// could choose to prune the tree on average 1 out of every 3 times it runs. /// To do that, it can call ShouldThrottle(1, 3) and prune if it returns true. /// </remarks> /// <returns>True if the caller should modify its behavior to reduce resources.</returns> public static bool ShouldThrottle(int numerator, int denominator) { return(numerator > DefaultRandomGenerator.GetGlobalRandomGenerator().Next(denominator)); }