private string MakeInsertId(Match match, InsertionType insertionType) { var insertId = id + "[" + (counter++) + "]"; texInserts.Add(insertId, Tuple.Create(match.Groups[2].Value, insertionType)); return(match.Groups[1].Value + "" + insertId + match.Groups[3].Value); }
public void Insert(int position, PositionType positionType, IEntity entity, InsertionType insertionType) { int actualPosition = positionType == PositionType.Absolute ? position : Index + position; if (insertionType == InsertionType.Before) { actualPosition--; } if (AssertIndex(actualPosition)) { Source.Insert(actualPosition, entity); } else { throw new ArgumentOutOfRangeException("position"); } if (OnChanged != null) { OnChanged(); } if (Index > actualPosition) { Index++; } }
private async Task <double[]> MeasureTimeAsync(InsertionType insertionType, Call[] calls) { var insert = GetInsert(insertionType); var runCase = GetRunCase(insert, calls); var measuredIterations = await runCase.MeasureTimeAsync().ConfigureAwait(false); return(measuredIterations); }
/// <summary> /// Bulk Insert /// </summary> public Insertion(float4x4 ltw, float2 *verts, int *amounts, int length) { Type = InsertionType.BulkInsert; Obstacle = default; Ltw = ltw; Vertices = verts; Amount = length; Amounts = amounts; }
/// <summary> /// Insert /// </summary> public Insertion(Entity obstacle, float4x4 ltw, float2 *vertices, int amount) { Type = InsertionType.Insert; Obstacle = obstacle; Ltw = ltw; Vertices = vertices; Amount = amount; Amounts = default; }
public IncrementalIQMManager(string path, CalculationType calcType = CalculationType.Modified, InsertionType insertionType = InsertionType.InsertInPlace, HandleResultsMethod handleResults = null) { FilePath = path; CalcType = calcType; InsertType = insertionType; HandleResults = handleResults ?? HandleResultsDefault; }
/// <summary> /// Sets the insertion method for execution. Normally with only two options I'd just use a conditional, /// but this allows for additional insertion options later /// </summary> /// <returns></returns> private static InsertMethod SetInsertionMethod(InsertionType insertType) { switch (insertType) { case InsertionType.AddAndSort: return(AddAndSort); default: return(InsertInPlace); } }
private async Task <MeasuredTime> GetMeasuredTimeAsync(InsertionType insertionType, Call[] calls, int batchSize) { var measuredIterations = await MeasureTimeAsync(insertionType, calls).ConfigureAwait(false); var average = measuredIterations.Average(); return(new MeasuredTime() { InsertionType = insertionType, Average = average, BatchSize = batchSize }); }
private void TestRun(CalculationType calcType, InsertionType insertType, int runCount, StreamWriter sw) { sw.Write($"{calcType.ToString()},{insertType.ToString()},"); var iqmm = new IncrementalIQMManager(PerformanceTestInputFilePath, calcType, insertType); var runtimes = new List <double>(); for (var i = 0; i < runCount; i++) { var runtime = iqmm.Execute(); runtimes.Add(runtime); sw.Write($"{runtime},"); } var avgRuntime = runtimes.Sum() / runtimes.Count; sw.WriteLine(avgRuntime); }
private IInsert GetInsert(InsertionType insertionType) { switch (insertionType) { case InsertionType.EntityFramework: return(_entityFrameworkInsert); case InsertionType.CompositeTypes: return(_compositeTypesInsert); case InsertionType.BinaryCopy: return(_binaryInsert); default: throw new ArgumentOutOfRangeException(); } }
public double Execute(string filePath, CalculationType calcType, InsertionType insertType, HandleResultsMethod handleResults = null) { if (string.IsNullOrEmpty(filePath)) { throw new ArgumentNullException(paramName: "FilePath", message: "File Path not defined"); } var InsertData = SetInsertionMethod(insertType); var CalculateMean = SetCalculateMethod(calcType); HandleResults = handleResults ?? HandleResults; // if a new HandleResultsMethod is passed use it DateTime beforeTime = DateTime.Now; try { List <int> data = new List <int>(); using (StreamReader sr = new StreamReader(filePath)) { var line = ""; // reads through each line in the file & calculates the intermediate IQM while ((line = sr.ReadLine()) != null) { InsertData(data, Convert.ToInt32(line)); if (data.Count >= 4) { var mean = CalculateMean(data); HandleResults(data.Count, mean); } } } } catch (Exception e) { Console.WriteLine("The file could not be read:"); Console.WriteLine(e.Message); } DateTime afterTime = DateTime.Now; TimeSpan diff = afterTime - beforeTime; return(diff.TotalMilliseconds); }
public double Execute(CalculationType calcType, InsertionType insertType) { return(Execute(FilePath, calcType, insertType)); }
public double Execute(InsertionType insertType) { return(Execute(FilePath, CalcType, insertType)); }
public Insertion(InsertionType type, string text, string?data) { this.Type = type; this.Data = data; this.Text = text; }
public void Add(InsertionType type, string text, string?data = null) => Insertions.Add(new Insertion(type, text, data));
private string MakeInsertId(Match match, InsertionType insertionType) { var insertId = id + "[" + (counter++) + "]"; texInserts.Add(insertId, Tuple.Create(match.Groups[2].Value, insertionType)); return match.Groups[1].Value + "" + insertId + match.Groups[3].Value; }