/// <summary> /// Deserializes stored data /// </summary> /// <param name="doInParaller">if set to <c>true</c> [do in paraller].</param> /// <returns></returns> protected Dictionary <String, T> GetDataItems(Boolean doInParaller = true) { aceConcurrentBag <instanceItemContainer <T> > bag = new aceConcurrentBag <instanceItemContainer <T> >(); Dictionary <String, T> output = new Dictionary <String, T>(); if (doInParaller) { Parallel.ForEach(bagContent, (i) => { bag.Add(GetItem(i)); }); } else { foreach (var i in bagContent) { bag.Add(GetItem(i)); } } foreach (var i in bag) { output.Add(i.id, i.instance); if (i.instance is IDataPackageItem) { IDataPackageItem item_IDataPackageItem = (IDataPackageItem)i.instance; item_IDataPackageItem.OnLoaded(); } } return(output); }
public void deploy(string crawlerName, moduleIterationRecordSummary modEnum, aceConcurrentBag <moduleIterationRecord> records, int DLCsCount) { ModuleName = crawlerName + "-" + modEnum.ToString(); Module = modEnum.ToString().imbTitleCamelOperation(true); double c = records.Count; iterationRecords = records.Count; InputTargets = records.Sum(x => x.inputTargets); ReductionTotal = records.Sum(x => x.output - x.inputTargets); ReductionAvg = ReductionTotal / c; reductionRate = ReductionTotal.GetRatio(InputTargets); potentialPrecissionChangeTotal = records.Sum(x => x.potentialPrecissionChange); potentialPrecissionChangeAvg = potentialPrecissionChangeTotal / c; processedTotal = records.Sum(x => x.processed); processedAvg = processedTotal / c; PotChangeIP = records.Sum(x => x.PotChangeIP).GetRatio(c); // PotOutputIP = records.Sum(x => x.PotOutputIP) / c; durationTotal = records.Sum(x => x.duration); durationAvgDLC = durationTotal / ((double)DLCsCount); durationAvgIteration = durationTotal.GetRatio(processedTotal); }
/// <summary> /// Adds the data items. /// </summary> /// <param name="items">The items.</param> /// <param name="doInParaller">if set to <c>true</c> [do in paraller].</param> /// <returns></returns> protected aceConcurrentBag <dataItemContainer> AddDataItems(IEnumerable <TWrapper> items, Boolean doInParaller = true) { aceConcurrentBag <dataItemContainer> bag = new aceConcurrentBag <dataItemContainer>(); if (doInParaller) { Parallel.ForEach(items, (i) => { bag.Add(AddDataItem(i)); }); } else { foreach (var i in items) { bag.Add(AddDataItem(i)); } } return(bag); }