private void ExecutePerformanceStudy(string testConfigurationFileName, bool shouldPersist) { PerformanceMonitor performanceMonitor = new PerformanceMonitor(InstanceToTrack.Global); // int maxPossibleCops = int.MaxValue / 100; int maxPossibleCops = 1000; ZppConfiguration.CacheManager.ReadInTestConfiguration(testConfigurationFileName); ICentralPlanningConfiguration testConfiguration = ZppConfiguration.CacheManager.GetTestConfiguration(); int customerOrderCount = ZppConfiguration.CacheManager.GetTestConfiguration() .CustomerOrderPartQuantity; int customerOrderCountOriginal = customerOrderCount; int elapsedMinutes = 0; int cycles = testConfiguration.SimulationMaximumDuration / testConfiguration.SimulationInterval; string performanceLogLastCycles = "["; // n cycles here each cycle create & plan configured CustomerOrderPart while (customerOrderCount <= maxPossibleCops && elapsedMinutes < 5) { InitThisTest(testConfigurationFileName); IZppSimulator zppSimulator = new global::Master40.SimulationMrp.impl.ZppSimulator(); performanceMonitor.Start(); zppSimulator.StartPerformanceStudy(shouldPersist); performanceMonitor.Stop(); if (performanceLogLastCycles.Length > 1) { performanceLogLastCycles += ","; } performanceLogLastCycles += "{" + performanceMonitor.ToString(); long currentMemoryUsage = Process.GetCurrentProcess().WorkingSet64; performanceLogLastCycles += $"\"CurrentMemoryUsage\": \"{currentMemoryUsage}\"" + Environment.NewLine; performanceLogLastCycles += "}" + Environment.NewLine; customerOrderCount += customerOrderCountOriginal; testConfiguration.CustomerOrderPartQuantity = customerOrderCount; } // just for correct log name customerOrderCount -= customerOrderCountOriginal; testConfiguration.CustomerOrderPartQuantity = customerOrderCount; performanceLogLastCycles += "]"; string logType = $"_{testConfiguration.Name}_cycles_{cycles}_COs_{testConfiguration.CustomerOrderPartQuantity}_lastCycles"; ; DebuggingTools.WritePerformanceLog(performanceLogLastCycles, logType); }
public static void WritePerformanceLog(string content, string type = "") { ICentralPlanningConfiguration testConfiguration = ZppConfiguration.CacheManager.GetTestConfiguration(); int cycles = testConfiguration.SimulationMaximumDuration / testConfiguration.SimulationInterval; if (type.Equals("")) { type = $"_{testConfiguration.Name}_cycles_{cycles}_COs_{testConfiguration.CustomerOrderPartQuantity}"; } WriteToFile($"{performanceLogFileName}{type}{defaultFileExtension}", content); }
public void Dispose() { _openDemandManager?.Dispose(); _openDemandManager = null; _dbMasterDataCache = null; _planningConfiguration = null; _productionDomainContext?.Database?.CloseConnection(); _dbTransactionData?.Dispose(); _productionDomainContextArchive?.Database?.CloseConnection(); _dbTransactionDataArchive?.Dispose(); _productionDomainContext = null; _productionDomainContextArchive = null; _dbTransactionData = null; _dbTransactionDataArchive = null; }
public void TestGeneratedQuantity() { ICentralPlanningConfiguration testConfiguration = ZppConfiguration.CacheManager.GetTestConfiguration(); int cycles = testConfiguration.SimulationMaximumDuration / testConfiguration.SimulationInterval; int totalCustomerOrdersToCreate = 500; int customerOrdersToCreate = totalCustomerOrdersToCreate / (cycles + 1); // round up CustomerOrderCreator og = new CustomerOrderCreator(null); og.CreateCustomerOrders(new SimulationInterval(0, 20160), new Quantity(totalCustomerOrdersToCreate)); IDbTransactionData dbTransactionData = ZppConfiguration.CacheManager.GetDbTransactionData(); var orders = dbTransactionData.CustomerOrderGetAll(); Assert.InRange(orders.Count(), customerOrdersToCreate, customerOrdersToCreate + 10); }
public void CreateCustomerOrders(SimulationInterval interval, Quantity customerOrderQuantity) { IDbTransactionData dbTransactionData = ZppConfiguration.CacheManager.GetDbTransactionData(); ICentralPlanningConfiguration testConfiguration = ZppConfiguration.CacheManager.GetTestConfiguration(); // skip creating COs, if goal has reached if (_createdCustomerOrdersCount >= testConfiguration.CustomerOrderPartQuantity) { return; } int cycles = testConfiguration.SimulationMaximumDuration / testConfiguration.SimulationInterval; int customerOrdersToCreate; int totalCustomerOrdersToCreate = (int)customerOrderQuantity.GetValue(); // TODO: PASCAL .GetValueOrDefault(); if (totalCustomerOrdersToCreate < cycles) { customerOrdersToCreate = totalCustomerOrdersToCreate; } else { customerOrdersToCreate = totalCustomerOrdersToCreate / (cycles + 1);// round up } List <T_CustomerOrder> createdCustomerOrders = new List <T_CustomerOrder>(); List <T_CustomerOrderPart> createdCustomerOrderParts = new List <T_CustomerOrderPart>(); while (createdCustomerOrders.Count < customerOrdersToCreate) { var creationTime = interval.StartAt; var endOrderCreation = interval.EndAt; while (creationTime < endOrderCreation) { var order = _orderGenerator.GetNewRandomOrder(time: creationTime); foreach (var orderPart in order.CustomerOrderParts) { orderPart.CustomerOrder = order; orderPart.CustomerOrderId = order.Id; createdCustomerOrderParts.Add(orderPart); } createdCustomerOrders.Add(order); // TODO : Handle this another way creationTime = order.CreationTime; if (createdCustomerOrders.Count >= customerOrdersToCreate) { break; } } } dbTransactionData.CustomerOrderPartAddAll(createdCustomerOrderParts); dbTransactionData.CustomerOrderAddAll(createdCustomerOrders); _createdCustomerOrdersCount += createdCustomerOrders.Count; }
public void ReadInTestConfiguration(string testConfigurationFileNames) { _planningConfiguration = JsonConvert.DeserializeObject <CentralPlanningConfiguration>( File.ReadAllText(testConfigurationFileNames)); }
/** * init db */ protected void InitTestScenario(string testConfiguration) { global::Zpp.ZppConfiguration.CacheManager.InitByReadingFromDatabase(testConfiguration, true); TestConfiguration = global::Zpp.ZppConfiguration.CacheManager.GetTestConfiguration(); ProductionDomainContext = global::Zpp.ZppConfiguration.CacheManager.GetProductionDomainContext(); }