public void BanchMark_TimeAlgoritm() { Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); _specificationWork = new SpecificationXmlWork(model: _specification); _specificationWork.GetResult(); stopwatch.Stop(); Console.WriteLine (value: $"Время обработки маленького файла в одном потоке: {stopwatch.Elapsed}"); stopwatch.Reset(); _specification = new Specification(); _loaderXml = new LoaderXml(pathXml: "specification.xml", model: _specification); _loaderXml.LoadData(); _specification = ((LoaderXml)_loaderXml).Model; stopwatch.Start(); _specificationWork = new SpecificationXmlWork(model: _specification); _specificationWork.GetResultAsync(); stopwatch.Stop(); Console.WriteLine ( value: $"Время обработки в многопоточном режиме маленького файла: {stopwatch.Elapsed}" ); _specification = new Specification(); _loaderXml = new LoaderXml(pathXml: "big_specification.xml", model: _specification); _loaderXml.LoadData(); _specification = ((LoaderXml)_loaderXml).Model; stopwatch.Start(); _specificationWork = new SpecificationXmlWork(model: _specification); _specificationWork.GetResult(); stopwatch.Stop(); Console.WriteLine (value: $"Время обработки в одном потоке большого файла: {stopwatch.Elapsed}"); stopwatch.Reset(); _specification = new Specification(); _loaderXml = new LoaderXml(pathXml: "big_specification.xml", model: _specification); _loaderXml.LoadData(); _specification = ((LoaderXml)_loaderXml).Model; stopwatch.Start(); _specificationWork = new SpecificationXmlWork(model: _specification); _specificationWork.GetResultAsync(); stopwatch.Stop(); Console.WriteLine ( value: $"Время обработки в многопоточном режиме большого файла: {stopwatch.Elapsed}" ); }
public void Execute(object parameter) { SpecificationPageViewModel specificationPageViewModel = parameter as SpecificationPageViewModel; // ReSharper disable once PossibleNullReferenceException if (string.IsNullOrEmpty(value: specificationPageViewModel.Path)) { Log.Log.SetLog(tag: Tag, message: "Параметр команды оказался пустым!"); return; } _loaderXml = new LoaderXml (pathXml: specificationPageViewModel.Path, model: new Specification()); _loaderXml.LoadData(); _specificationWork = new SpecificationXmlWork(model: _loaderXml.Model); ArrayList listResult; Task task = new Task ( action: () => { //TODO: Если файл небольшой, то потребности в ногопотоке нет listResult = _specificationWork.GetResultAsync().ArrayList; specificationPageViewModel.ResultSpecificationsItems = null; specificationPageViewModel.ResultSpecificationsItems = listResult.Cast <ResultSpecification>(); _loadFile = false; specificationPageViewModel.StatusTime = "Время операци: " + $"{_stopwatch.Elapsed:g}"; _stopwatch.Stop(); _stopwatch.Reset(); } ); Task animationTask = new Task (action: () => Animation(specificationPageViewModel: specificationPageViewModel)); _stopwatch.Start(); _loadFile = true; task.Start(); animationTask.Start(); }