public async Task DispatchEffectsAsync(PropagationEffects effects) { await StatsHelper.RegisterMsg("EffectsDispatcherGrain::DispatchEffects", this.GrainFactory); Logger.LogInfoForDebug(this.GetLogger(), "@@[Dispatcher {0}] Dequeuing effects", this.GetPrimaryKey()); this.lastProcessingTime = DateTime.UtcNow; this.isDispatchingEffects = true; if (this.status != EffectsDispatcherStatus.Busy) { Logger.LogForRelease(this.GetLogger(), "@@[Dispatcher {0}] Becoming busy (before was {1})", this.GetPrimaryKey(), this.status); var oldStatus = this.status; this.status = EffectsDispatcherStatus.Busy; if (oldStatus == EffectsDispatcherStatus.Idle) { // Notify that the dispatcher is busy this.subscriptionManager.Notify(s => s.OnEffectsDispatcherStatusChanged(this, this.status)); } } await this.effectsDispatcher.DispatchEffectsAsync(effects); this.lastProcessingTime = DateTime.UtcNow; this.isDispatchingEffects = false; }
public void CalculateZScore() { var statsHelper = new StatsHelper(); var zScore = statsHelper.CalculateZScore(55, 35, 5); Assert.AreEqual(zScore, 4); }
public async Task <PropagationEffects> PropagateAsync(PropagationKind propKind) { await StatsHelper.RegisterMsg("MethodEntityGrain::Propagate", this.GrainFactory); //if (status.Equals(EntityGrainStatus.Busy)) //{ // await Task.Delay(WAIT_TIME); // if (status.Equals(EntityGrainStatus.Busy)) // { // return new PropagationEffects(); // } //} Logger.LogVerbose(this.GetLogger(), "MethodEntityGrain", "Propagate", "Propagation for {0} ", this.methodEntity.MethodDescriptor); var sw = new Stopwatch(); sw.Start(); var propagationEffects = await this.methodEntityPropagator.PropagateAsync(propKind); sw.Stop(); propagationEffects.SiloAddress = StatsHelper.GetMyIPAddr(); Logger.LogInfo(this.GetLogger(), "MethodEntityGrain", "Propagate", "End Propagation for {0}. Time elapsed {1} Effects size: {2}", this.methodEntity.MethodDescriptor, sw.Elapsed, propagationEffects.CalleesInfo.Count); await StatsHelper.RegisterPropagationUpdates(propagationEffects.NumberOfUpdates, propagationEffects.WorkListInitialSize, this.GrainFactory); return(propagationEffects); }
protected override void RunAction() { if (closedTasksGroup != null) { DateTime today = DateTime.Today; using (IRepository <Task, long> repository = PersistentFactory.GetContext().GetRepository <Task, long>()) { foreach (Task task in closedTasksGroup.AllTasks.ToList()) { if ((today - task.Closed).TotalDays > 60) { task.State = TaskState.Archived; closedTasksGroup.Dispatcher.Invoke(() => closedTasksGroup.RemoveTask(task)); repository.Update(task); StatsHelper.Update(StatsData.TaskArchived); NotificationHelper.Notify(NotificationType.TaskArchived, task.Name); Log.Debug($"Background action archived {task.Name} task", this); } } } } }
public ContextSensitiveSpellingCorrection(IPOSTagger posTagger, IEnumerable <string> corpora, IEnumerable <string[]> confusionSets, bool prune) { _posTagger = posTagger; _contextFeaturesExtractor = new ContextFeaturesExtractor(k); _collocationtFeaturesExtractor = new CollocationFeaturesExtractor(l); _statsHelper = new StatsHelper(); _comparators = new List <Comparator>(confusionSets.Count()); Sentence[] sentences = PreProcessCorpora(corpora).ToArray(); /*processed corpus was serialized for faster results between trials*/ XmlSerializer x = new XmlSerializer(typeof(Sentence[])); FileStream fs = new FileStream(@"Sentence.xml", FileMode.Open); x.Serialize(fs, sentences); fs.Close(); sentences = (Sentence[])x.Deserialize(new FileStream(@"Sentence.xml", FileMode.Open)); Console.WriteLine("Deserialize complete"); var featureFrequencies = new Dictionary <string, Dictionary <string, int> >(StringComparer.OrdinalIgnoreCase); if (prune) { /* preprocess terms' frequencies */ featureFrequencies = _statsHelper.GetFrequencies(sentences); } Parallel.ForEach(confusionSets, confusionSet => { TrainingData output = GenerateTrainingData(sentences, prune, featureFrequencies, confusionSet); Train(confusionSet, output.Features.ToArray(), output.Samples); }); }
/// <summary> /// /// </summary> /// <param name="trainingDataSize">Window size to calculate running average and standardeviation</param> /// <param name="outlierThreshHold">Threshold to determine if point is outlier</param> /// <param name="statsHelper">Helper class to do statistical calculation</param> public ZScoreDeviation(int trainingDataSize, double outlierThreshHold, StatsHelper statsHelper) { _trainingDataSize = trainingDataSize; _outlierThreshHold = outlierThreshHold; _statsHelper = statsHelper; _trainingData = new Queue <DataItemDto>(); }
public Task <IMethodEntityWithPropagator> GetMethodEntityAsync(MethodDescriptor methodDescriptor) { //StatsHelper.RegisterMsg("SolutionGrain::GetMethodEntity:"+methodDescriptor, this.GrainFactory); StatsHelper.RegisterMsg("SolutionGrain::GetMethodEntity", this.GrainFactory); return(this.solutionManager.GetMethodEntityAsync(methodDescriptor)); }
public async Task <IDictionary <AnalysisCallNode, ISet <MethodDescriptor> > > GetCalleesInfoAsync() { await StatsHelper.RegisterMsg("MethodEntityGrain::GetCalleesInfo", this.GrainFactory); var result = await this.methodEntityPropagator.GetCalleesInfoAsync(); return(result); }
public async Task <ISet <MethodDescriptor> > GetCalleesAsync() { await StatsHelper.RegisterMsg("MethodEntityGrain::GetCallees", this.GrainFactory); var result = await this.methodEntityPropagator.GetCalleesAsync(); return(result); }
public OveralStats GatherOveralStats() { var stats = StatsHelper.GatherOveralStatistics2(_work.GetAll()); stats.IsStopped = _stopped; stats.StartTime = _sartTime; return(stats); }
public SchedulerStats GatherStats(string filter = null) { return(new SchedulerStats { Overal = GatherOveralStats(), CurrentJobs = StatsHelper.GatherCurrentJobs(_work.GetAll(), filter) }); }
public Task <MethodDescriptor> FindMethodImplementationAsync(MethodDescriptor methodDescriptor, TypeDescriptor typeDescriptor) { StatsHelper.RegisterMsg("ProjectGrain::FindMethodImplementation", this.GrainFactory); //var methodImplementationDescriptor = this.projectCodeProvider.FindMethodImplementation(methodDescriptor, typeDescriptor); //return Task.FromResult<MethodDescriptor>(methodImplementationDescriptor); return(this.projectCodeProvider.FindMethodImplementationAsync(methodDescriptor, typeDescriptor)); }
public MainWindow() { InitializeComponent(); StatsHelper.InitialiseFromFile(); NextQuestion(); }
//Abilites modifier // Use this for initialization void Awake() { ins = this; GenerateLevelValuesArray(); GeneratePriceValuesArray(); GenerateWaveDifficultyArray(); Debug.Log(GetTimeStringFromFloat(4000, true)); }
public void CalculateStandardDeviation() { var statsHelper = new StatsHelper(); var std = statsHelper.CalculateStandardDeviation(new List <double> { 10, 20, 38, 23, 38, 23, 21 }); Assert.AreEqual(Math.Round(std), 9); }
//private ProjectState State; //private Task WriteStateAsync() //{ // return TaskDone.Done; //} //private Task ClearStateAsync() //{ // return TaskDone.Done; //} public override async Task OnActivateAsync() { //this.State = new ProjectState(); await StatsHelper.RegisterActivation("ProjectCodeProviderGrain", this.GrainFactory); Logger.OrleansLogger = this.GetLogger(); Logger.LogInfo(this.GetLogger(), "ProjectGrain", "OnActivate", "Enter"); // Logger.LogWarning(this.GetLogger(), "ProjectGrain", "OnActivate", "Entering Project: {0}", this.GetPrimaryKeyString()); this.observers = new ObserverSubscriptionManager <IEntityGrainObserverNotifications>(); this.State.AssemblyName = this.GetPrimaryKeyString(); //Task.Run(async () => //await Task.Factory.StartNew(async () => //{ try { this.RaiseStateChangedEvent(EntityGrainStatus.Busy); if (!string.IsNullOrEmpty(this.State.ProjectPath)) { this.projectCodeProvider = await OrleansProjectCodeProvider.CreateFromProjectAsync(this.GrainFactory, this.State.ProjectPath); } else if (!string.IsNullOrEmpty(this.State.Source) && !String.IsNullOrEmpty(this.State.AssemblyName)) { this.projectCodeProvider = await OrleansProjectCodeProvider.CreateFromSourceAsync(this.GrainFactory, this.State.Source, this.State.AssemblyName); } else if (!string.IsNullOrEmpty(this.State.TestName) && !String.IsNullOrEmpty(this.State.AssemblyName)) { this.projectCodeProvider = await OrleansProjectCodeProvider.CreateFromTestAsync(this.GrainFactory, this.State.TestName, this.State.AssemblyName); } else if (this.State.AssemblyName.Equals("DUMMY")) { this.projectCodeProvider = new OrleansDummyProjectCodeProvider(this.GrainFactory); await this.WriteStateAsync(); } this.RaiseStateChangedEvent(EntityGrainStatus.Ready); } catch (Exception ex) { var inner = ex; while (inner is AggregateException) { inner = inner.InnerException; } Logger.LogError(this.GetLogger(), "ProjectGrain", "OnActivate", "Error:\n{0}\nInner:\n{1}", ex, inner); throw ex; } //}); Logger.LogInfo(this.GetLogger(), "ProjectGrain", "OnActivate", "Exit"); }
public async Task ReplaceDocumentSourceAsync(string source, string documentPath) { await StatsHelper.RegisterMsg("ProjectGrain::ReplaceDocumentSource", this.GrainFactory); this.State.Source = source; await this.WriteStateAsync(); await this.projectCodeProvider.ReplaceDocumentSourceAsync(source, documentPath); }
public void CalculateMean() { var statsHelper = new StatsHelper(); var mean = statsHelper.CalculateMean(new List <double> { 5, 10, 15, 20, 25 }); Assert.AreEqual(mean, 15); }
public override Task OnDeactivateAsync() { StatsHelper.RegisterDeactivation("MethodEntityGrain", this.GrainFactory); Logger.LogWarning(this.GetLogger(), "MethodEntityGrain", "OnDeactivate", "Deactivation for {0} ", this.GetPrimaryKeyString()); this.methodEntity = null; return(Task.CompletedTask); }
public void MakeStats(UnitBaseStats stats) { if (m_stats == null) { m_stats = gameObject.AddComponent <UnitStats>(); } m_stats.Init(StatsHelper.GetStatListForInit(baseStats), null); }
static UnitStats MakeStats(GameObject target, ScriptableUnitConfig conf, Unit_EffectManager effects, M_Math.R_Range range) { UnitStats stats = target.AddComponent <UnitStats>(); conf.BaseStats.StartTurnTime = range; stats.Init(StatsHelper.GetStatListForInit(conf.BaseStats), effects); return(stats); }
public async Task RelocateAsync(string projectPath) { await StatsHelper.RegisterMsg("ProjectGrain::Relocate", this.GrainFactory); this.State.ProjectPath = projectPath; await this.WriteStateAsync(); await this.projectCodeProvider.RelocateAsync(projectPath); }
public async Task PropagateAndProcessAsync(ReturnMessageInfo returnMessageInfo) { await StatsHelper.RegisterMsg("MethodEntityGrain::PropagateAndProcess", this.GrainFactory); var effects = await this.methodEntityPropagator.PropagateAsync(returnMessageInfo); //await this.PropagateAsync(returnMessageInfo); await StatsHelper.RegisterPropagationUpdates(effects.NumberOfUpdates, effects.WorkListInitialSize, this.GrainFactory); await ProcessEffectsAsync(effects); }
public async Task PropagateAndProcessAsync(PropagationKind propKind, IEnumerable <PropGraphNodeDescriptor> reWorkSet) { await StatsHelper.RegisterMsg("MethodEntityGrain::PropagateAndProcess", this.GrainFactory); var effects = await this.methodEntityPropagator.PropagateAsync(propKind, reWorkSet); // await this.PropagateAsync(propKind, reWorkSet); await StatsHelper.RegisterPropagationUpdates(effects.NumberOfUpdates, effects.WorkListInitialSize, this.GrainFactory); await ProcessEffectsAsync(effects); }
private void Percentage_Click(object sender, RoutedEventArgs e) { int percentage = Int32.Parse((string)((Button)sender).Tag); if (currentThing != null && !currentThing.YesCounters.ContainsKey(currentQuestion)) { currentThing.YesCounters.Add(currentQuestion, new Tuple <int, int>(percentage, 100)); } StatsHelper.SaveToFile(); NextQuestion(); }
public IOutlierCalculator Create(OutlierCalcType calcType) { if (calcType == OutlierCalcType.ZScore) { var trainingDataSize = int.Parse(ConfigurationManager.AppSettings["ZScoreDeviation.TraingSetSize"]); var outlierThreshHold = double.Parse(ConfigurationManager.AppSettings["ZScoreDeviation.OutlierThreshHold"]); var statsHelper = new StatsHelper(); return(new ZScoreDeviation(trainingDataSize, outlierThreshHold, statsHelper)); } return(null); }
public async Task MessagesStats() { try { using (var stream = StatsHelper.GetMessageGraph(DateTime.Now.AddDays(-7), DateTime.Now, 60)) await Context.Channel.SendFileAsync(stream, "graph.png"); } catch (Exception ex) { await Context.Channel.SendMessageAsync(ex.ToString().Substring(0, Math.Min(ex.ToString().Length, 1990))); } }
public Task <bool> IsSubtypeAsync(TypeDescriptor typeDescriptor1, TypeDescriptor typeDescriptor2) { StatsHelper.RegisterMsg("ProjectGrain::IsSubtype", this.GrainFactory); //if (GrainClient.IsInitialized) //{ // Logger.LogWarning(GrainClient.Logger, "ProjectGrain", "IsSubtypeAsync", "type1={0}, type2={1}", typeDescriptor1, typeDescriptor2); //} //Console.WriteLine("ProjectGrain::IsSubtypeAsync type1={0}, type2={1}", typeDescriptor1, typeDescriptor2); return(this.projectCodeProvider.IsSubtypeAsync(typeDescriptor1, typeDescriptor2)); }
//private SolutionState State; //private Task WriteStateAsync() //{ // return TaskDone.Done; //} //private Task ClearStateAsync() //{ // return TaskDone.Done; //} public override async Task OnActivateAsync() { //this.State = new SolutionState(); await StatsHelper.RegisterActivation("SolutionGrain", this.GrainFactory); Logger.OrleansLogger = this.GetLogger(); Logger.LogInfo(this.GetLogger(), "SolutionGrain", "OnActivate", "Enter"); this.projectsReadyCount = 0; //Task.Run(async () => //await Task.Factory.StartNew(async () => //{ try { if (!string.IsNullOrEmpty(this.State.SolutionPath)) { this.solutionManager = await OrleansSolutionManager.CreateFromSolutionAsync(this, this.GrainFactory, this.State.SolutionPath); } else if (!string.IsNullOrEmpty(this.State.Source)) { this.solutionManager = await OrleansSolutionManager.CreateFromSourceAsync(this, this.GrainFactory, this.State.Source); } else if (!string.IsNullOrEmpty(this.State.TestName)) { this.solutionManager = await OrleansSolutionManager.CreateFromTestAsync(this, this.GrainFactory, this.State.TestName); } //if (this.solutionManager != null) //{ // await this.WaitForAllProjects(); //} } catch (Exception ex) { var inner = ex; while (inner is AggregateException) { inner = inner.InnerException; } Logger.LogError(this.GetLogger(), "SolutionGrain", "OnActivate", "Error:\n{0}\nInner:\n{1}", ex, inner); throw ex; } //}); Logger.LogInfo(this.GetLogger(), "SolutionGrain", "OnActivate", "Exit"); }
//public Task AddInstantiatedTypesAsync(IEnumerable<TypeDescriptor> types) //{ // StatsHelper.RegisterMsg("SolutionGrain::AddInstantiatedTypes", this.GrainFactory); // return solutionManager.AddInstantiatedTypesAsync(types); //} //public Task<ISet<TypeDescriptor>> GetInstantiatedTypesAsync() //{ // StatsHelper.RegisterMsg("SolutionGrain::GetInstantiatedTypes", this.GrainFactory); // return this.solutionManager.GetInstantiatedTypesAsync(); //} public async Task <IEnumerable <MethodDescriptor> > GetRootsAsync(AnalysisRootKind rootKind = AnalysisRootKind.Default) { await StatsHelper.RegisterMsg("SolutionGrain::GetRoots", this.GrainFactory); Logger.LogVerbose(this.GetLogger(), "SolutionGrain", "GetRoots", "Enter"); var sw = new Stopwatch(); sw.Start(); var roots = await this.solutionManager.GetRootsAsync(rootKind); Logger.LogInfo(this.GetLogger(), "SolutionGrain", "GetRoots", "End Time elapsed {0}", sw.Elapsed); return(roots); }