Esempio n. 1
0
        private static void ProcessAndUploadDataSet(ReddDataSet dataSet, PerformanceResult performanceResult, int bulkSize)
        {
            using (MySqlConnection insertConnection = new MySqlConnection(ConnectionString))
            {
                insertConnection.Open();
                var sw = Stopwatch.StartNew();

                var rows = new List <string>();
                int pos  = 0;
                foreach (var line in File.ReadLines(dataSet.FilePath))
                {
                    var split = line.Split(' ');
                    var date  = FromUnixTime(long.Parse(split[0]));
                    rows.Add($"({split[1]}, {dataSet.Id},{date.Day}, {date.Month})");
                    if (++pos % bulkSize == 0)
                    {
                        StoreDataOnServer(rows, insertConnection);
                    }
                }

                //Store the remaining rows
                StoreDataOnServer(rows, insertConnection);
                performanceResult.InsertTimeMs    = sw.ElapsedMilliseconds;
                performanceResult.NumberOfNewRows = dataSet.LineCount;
            }
        }
Esempio n. 2
0
        public static PerformanceResult BenchmarkDataSet(ReddDataSet dataSet, int numOfRepetitions = 5)
        {
            var performanceResult = new PerformanceResult {
                DataSet = dataSet
            };


            ProcessAndUploadDataSet(dataSet, performanceResult, 100000);

            BenchmarkServerCalculation(performanceResult, numOfRepetitions);

            return(performanceResult);
        }
Esempio n. 3
0
 private static void BenchmarkServerCalculation(PerformanceResult performanceResult, int numOfRepetitions = 5)
 {
     for (var i = 0; i < numOfRepetitions; i++)
     {
         var sw = Stopwatch.StartNew();
         using (var calculationConnection = new MySqlConnection(ConnectionString))
         {
             calculationConnection.Open();
             LogCommand(CalculateCommandString);
             var calculateCommand = new MySqlCommand(CalculateCommandString, calculationConnection);
             SetupCommand(calculateCommand);
             var       reader = calculateCommand.ExecuteReader();
             DataTable dt     = new DataTable();
             dt.Load(reader);
             performanceResult.AddCalculationResult(dt.Rows.Count, sw.ElapsedMilliseconds);
         }
     }
 }