public void GetAverageCpuTest_MoreThenStored() { var proc = Process.GetCurrentProcess(); ProcessStatistics stats = new ProcessStatistics(proc.Id, proc.ProcessName); stats.Stats.AddRange(Usage); var averageOf12 = stats.GetAverageCpu(12); Assert.IsTrue(averageOf12 == (double)(1 + 2 + 3 + 4 + 5) / 5); }
public void GetAverageRamTest() { var proc = Process.GetCurrentProcess(); ProcessStatistics stats = new ProcessStatistics(proc.Id, proc.ProcessName); stats.Stats.AddRange(Usage); var averageOf3 = stats.GetAverageRam(3); Assert.IsTrue(averageOf3 == (double)(3 + 4 + 5) / 3); }
private void AddProcess(int processId, string processName) { if (processId == 0 || processName == "Idle" || processName == "Memory Compression") { return; } var stat = new ProcessStatistics(processId, processName); ProcessStatistics.Add(stat); }
/// <summary> /// This function is called when DataPort has completed the import. /// </summary> /// <param name="stats">The statistics of what occurred in the import including things like the number created, updated or the errors that occurred.</param> /// <param name="additionalData">Reserved for passing additional data through. As of December 2016 only the DBid is provided.</param> public void ImportCompleted(ProcessStatistics stats, Dictionary <AdditionalDataKeys, DescriptiveData> additionalData) { }
public override void _Ready() { if (cloudSystem == null && !IsForPreviewOnly) { throw new Exception("Microbe not initialized"); } if (onReadyCalled) { return; } atp = SimulationParameters.Instance.GetCompound("atp"); Membrane = GetNode <Membrane>("Membrane"); OrganelleParent = GetNode <Spatial>("OrganelleParent"); bindingAudio = GetNode <AudioStreamPlayer3D>("BindingAudio"); movementAudio = GetNode <AudioStreamPlayer3D>("MovementAudio"); cellBurstEffectScene = GD.Load <PackedScene>("res://src/microbe_stage/particles/CellBurstEffect.tscn"); engulfAudio = new HybridAudioPlayer(!IsPlayerMicrobe) { Stream = GD.Load <AudioStream>("res://assets/sounds/soundeffects/engulfment.ogg"), Bus = "SFX", }; AddChild(engulfAudio); // You may notice that there are two separate ways that an audio is played in this class: // using pre-existing audio node e.g "bindingAudio", "movementAudio" and through method e.g "PlaySoundEffect", // "PlayNonPositionalSoundEffect". The former is approach best used to play looping sounds with more control // to the audio player while the latter is more convenient for dynamic and various short one-time sound effects // in expense of lesser audio player control. if (IsPlayerMicrobe) { // Creates and activates the audio listener for the player microbe. Positional sound will be // received by it instead of the main camera. listener = new Listener(); AddChild(listener); listener.MakeCurrent(); // Setup tracking running processes ProcessStatistics = new ProcessStatistics(); GD.Print("Player Microbe spawned"); } // Setup physics callback stuff var engulfDetector = GetNode <Area>("EngulfDetector"); engulfShape = (SphereShape)engulfDetector.GetNode <CollisionShape>("EngulfShape").Shape; engulfDetector.Connect("body_entered", this, nameof(OnBodyEnteredEngulfArea)); engulfDetector.Connect("body_exited", this, nameof(OnBodyExitedEngulfArea)); ContactsReported = Constants.DEFAULT_STORE_CONTACTS_COUNT; Connect("body_shape_entered", this, nameof(OnContactBegin)); Connect("body_shape_exited", this, nameof(OnContactEnd)); Mass = Constants.MICROBE_BASE_MASS; if (IsLoadedFromSave) { // Fix the tree of colonies if (ColonyChildren != null) { foreach (var child in ColonyChildren) { AddChild(child); } } // Need to re-attach our organelles foreach (var organelle in organelles) { OrganelleParent.AddChild(organelle); } // Colony children shapes need re-parenting to their master // The shapes have to be re-parented to their original microbe then to the master again, maybe engine bug // Also re-add to the collision exception and change the mode to static as it should be if (Colony != null && this != Colony.Master) { ReParentShapes(this, Vector3.Zero); ReParentShapes(Colony.Master, GetOffsetRelativeToMaster()); Colony.Master.AddCollisionExceptionWith(this); AddCollisionExceptionWith(Colony.Master); Mode = ModeEnum.Static; } // And recompute storage RecomputeOrganelleCapacity(); // Do species setup that we need on load SetScaleFromSpecies(); SetMembraneFromSpecies(); } onReadyCalled = true; }
void pInfo_updateEvent(object sender, ProcessStatsEventArgs eventArgs) { setText(ProcessStatistics.dumpProcStats(eventArgs)); addData(eventArgs); }
/// <summary> /// This function is called when DataPort has completed the import. /// </summary> /// <param name="stats">The statistics of what occurred in the import including things like the number created, updated or the errors that occurred.</param> /// <param name="additionalData">Reserved for passing additional data through. As of December 2016 only the DBid is provided.</param> public void ImportCompleted(ProcessStatistics stats, Dictionary <AdditionalDataKeys, DescriptiveData> additionalData) { // You may want to write the stats to your own file or send an email or anything else that pleases you... }