예제 #1
0
        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++;
            }
        }
예제 #3
0
        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);
        }
예제 #4
0
 /// <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;
 }
예제 #5
0
 /// <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;
 }
예제 #6
0
 public IncrementalIQMManager(string path,
                              CalculationType calcType          = CalculationType.Modified,
                              InsertionType insertionType       = InsertionType.InsertInPlace,
                              HandleResultsMethod handleResults = null)
 {
     FilePath      = path;
     CalcType      = calcType;
     InsertType    = insertionType;
     HandleResults = handleResults ?? HandleResultsDefault;
 }
예제 #7
0
        /// <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);
            }
        }
예제 #8
0
        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
            });
        }
예제 #9
0
        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);
        }
예제 #10
0
        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();
            }
        }
예제 #11
0
        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);
        }
예제 #12
0
 public double Execute(CalculationType calcType, InsertionType insertType)
 {
     return(Execute(FilePath, calcType, insertType));
 }
예제 #13
0
 public double Execute(InsertionType insertType)
 {
     return(Execute(FilePath, CalcType, insertType));
 }
예제 #14
0
파일: Content.cs 프로젝트: pipe01/SharpVue
 public Insertion(InsertionType type, string text, string?data)
 {
     this.Type = type;
     this.Data = data;
     this.Text = text;
 }
예제 #15
0
파일: Content.cs 프로젝트: pipe01/SharpVue
 public void Add(InsertionType type, string text, string?data = null)
 => Insertions.Add(new Insertion(type, text, data));
예제 #16
0
		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;
		}