/// <summary> /// Creates a benchmark container. /// </summary> /// <returns>A benchmark container</returns> public static IBenchmarkContainer <T> CreateBenchmarkContainer(BenchmarkContainerType type, T[] tuples) { switch (type) { case BenchmarkContainerType.HashSet: return(HashSetBenchmarkContainer <T> .Create(tuples)); case BenchmarkContainerType.LinkedList: return(LinkedListBenchmarkContainer <T> .Create(tuples)); case BenchmarkContainerType.Queue: return(QueueBenchmarkContainer <T> .Create(tuples)); case BenchmarkContainerType.SortedDictionary: return(SortedDictionaryBenchmarkContainer <T> .Create(tuples)); case BenchmarkContainerType.SortedList: return(SortedListBenchmarkContainer <T> .Create(tuples)); default: throw new ArgumentException("Type not supported", nameof(type)); } }
/// <summary> /// Initializes a new instance of the <see cref="BenchmarkResult" /> class. /// </summary> public BenchmarkResult(BenchmarkContainerType containerType, long cardinality) { this.ContainerType = containerType; this.Cardinality = cardinality; this.Scores = new Dictionary <BenchmarkOperation, double>(); }
/// <summary> /// Gets the result key. /// </summary> /// <param name="containerType">Type of the container.</param> /// <param name="cardinality">The cardinality.</param> /// <returns>A string</returns> private static string GetResultKey(BenchmarkContainerType containerType, long cardinality, BenchmarkOperation operation) { return($"{containerType}\\{cardinality}\\{operation}"); }
/// <summary> /// Gets the header string. /// </summary> /// <param name="cardinalities">The cardinalities.</param> /// <returns>A string</returns> private static string GetHeader(BenchmarkContainerType containerType, IEnumerable <long> cardinalities) { return($"{containerType} Scores\nOperation\\Cardinality," + string.Join(',', cardinalities.Select(c => c.ToString())) + "\n"); }