private void UpdateGuiLogPreview(PerformanceState state) { PerformanceStateList.Add(state); if (PerformanceStateList.Count > 50 && PerformanceStateList.Count > _measurementTimeInterval) { // keep the GUI list small PerformanceStateList.RemoveAt(0); } }
public PerformanceStateViewModel(PerformanceState state) { CpuUsagePercentage = state.CpuUsagePercentage; CpuTotalProcessUsagePercentage = state.CpuTotalProcessUsagePercentage; WorkingSetBytes = state.WorkingSetBytes; TotalMemoryBytes = state.TotalMemoryBytes; TotalCpus = state.TotalCpus; ThredCount = state.ThredCount; TimeStamp = state.TimeStamp; }
public static string GetMessageForStateLog(PerformanceState state) { _result.Clear(); _result.Append($"{state.TimeStamp:HH:mm:ss}, "); _result.Append($"{state.CpuTotalProcessUsagePercentage}, "); _result.Append($"{string.Join(", ", state.CpuUsagePercentage)}, "); _result.Append($"{state.TotalMemoryBytes}, "); _result.Append($"{state.WorkingSetBytes}, "); _result.Append($"{state.ThredCount}"); return(_result.ToString()); }
public static string GetMessageForConcole(PerformanceState state) { _result.Clear(); _result.Append($"{state.TimeStamp:HH:mm:ss}, "); _result.Append($"CPU Proc:{state.CpuTotalProcessUsagePercentage,3:###}%, "); _result.Append($"{string.Join(", ", state.CpuUsagePercentage.Select((cpu, i) => $"CPU{i}:{cpu,3:###}%"))}, "); _result.Append($"TotalMemory:{state.TotalMemoryBytes / 1024 / 1024,4:####} Mb, "); _result.Append($"WorkingSet:{state.WorkingSetBytes / 1024 / 1024,4:####} Mb, "); _result.Append($"Threads:{state.ThredCount}"); return(_result.ToString()); }
public static string GetMessageForStateLogHeader(PerformanceState state) { _result.Clear(); _result.Append("Timestamp, "); _result.Append("CPU Total%, "); _result.Append($"{string.Join(", ", state.CpuUsagePercentage.Select((cpu,i) => $"CPU{ i}% "))}, "); _result.Append($"{nameof(state.TotalMemoryBytes)}, "); _result.Append($"{nameof(state.WorkingSetBytes)}, "); _result.Append($"{nameof(state.ThredCount)}"); _result.Append("CPU Total%, "); return(_result.ToString()); }
public override int GetHashCode() { unchecked { int hashCode = (MinerName != null ? MinerName.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (MinerVersion != null ? MinerVersion.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (ApiVersion != null ? ApiVersion.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (MiningUrl != null ? MiningUrl.GetHashCode() : 0); hashCode = (hashCode * 397) ^ Intensity.GetHashCode(); hashCode = (hashCode * 397) ^ (PerformanceState != null ? PerformanceState.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (BiosVersion != null ? BiosVersion.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (DriverVersion != null ? DriverVersion.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (OperatingSystem != null ? OperatingSystem.GetHashCode() : 0); return(hashCode); } }
public void CpuPeakReachedTest() { var definitions = new List <AlertDefinition>(); NotificationManager manager = new NotificationManager(definitions, null); int current = 60, average1 = 59, average2 = current, average3 = 61; var eventT1 = new PerformanceState() { AverageCPU = current }; manager.Update(eventT1); var definition1 = new AlertDefinition(NotificationProviderMock.Object) { AvergareCPU = average1, AvergareRAM = 30, MeasurementTime = 10 }; var definition2 = new AlertDefinition(NotificationProviderMock.Object) { AvergareCPU = average2, AvergareRAM = 30, MeasurementTime = 10 }; var definition3 = new AlertDefinition(NotificationProviderMock.Object) { AvergareCPU = average3, AvergareRAM = 30, MeasurementTime = 10 }; PrivateObject obj = new PrivateObject(manager); var value1 = (bool)obj.Invoke("PeakReached", new object[] { definition1, 1 }); var value2 = (bool)obj.Invoke("PeakReached", new object[] { definition2, 1 }); var value3 = (bool)obj.Invoke("PeakReached", new object[] { definition3, 1 }); Assert.IsTrue(value1); Assert.IsFalse(value2); Assert.IsFalse(value3); }
public void GetAverageCpuTest() { var definitions = new List <AlertDefinition>(); NotificationManager manager = new NotificationManager(definitions, null); int v1 = 35, v2 = 60, v3 = 25; var eventT1 = new PerformanceState() { AverageCPU = v1 }; var eventT2 = new PerformanceState() { AverageCPU = v2 }; var eventT3 = new PerformanceState() { AverageCPU = v3 }; manager.Update(eventT1); manager.Update(eventT2); manager.Update(eventT3); manager.AlertDefinitions.Add(new AlertDefinition(NotificationProviderMock.Object) { AvergareCPU = 30, AvergareRAM = 30, MeasurementTime = 10 }); PrivateObject obj = new PrivateObject(manager); var value1 = (int)obj.Invoke("GetAverageCpu", new object[] { 1 }); var value2 = (int)obj.Invoke("GetAverageCpu", new object[] { 2 }); var value3 = (int)obj.Invoke("GetAverageCpu", new object[] { 3 }); Assert.IsTrue(value1 == v3); Assert.IsTrue(value2 == (v3 + v2) / 2); Assert.IsTrue(value3 == (v1 + v2 + v3) / 3); }
public void UpdateEventListTest() { var definitions = new List <AlertDefinition>(); NotificationManager manager = new NotificationManager(definitions, null); var eventT1 = new PerformanceState(); var eventT2 = new PerformanceState(); var eventT3 = new PerformanceState(); var prop = manager.GetType().GetField("PerformanceStateList", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance); var eventList = (List <IPerformanceState>)prop.GetValue(manager); Assert.IsTrue(eventList.Count() == 0); manager.Update(eventT1); manager.Update(eventT2); manager.Update(eventT3); Assert.IsTrue(eventList.Count() == 3); }
private void QueryState() { // Generate new state var newState = new PerformanceState { CpuTotalProcessUsagePercentage = GetCpuTotalProcessUsagePercentageValue(), CpuUsagePercentage = GetCpuUsagePercentageValues(), WorkingSetBytes = GetWorkingSetBytesValue(), TotalMemoryBytes = GetTotalMemoryBytesValue(), ThredCount = GetThredCountValue(), TotalCpus = _cpuCount, TimeStamp = DateTime.UtcNow }; _queryQueue.Enqueue(newState); // Cycle buffer behaviour // Calling count is O(n), but performance is not important here while (_queryQueue.Count > _limitQueryQueue) { GetCounters(); } }
public Horizon(Switch device) { KernelContext = new KernelContext( device, device.Memory, device.Configuration.MemoryConfiguration.ToKernelMemorySize(), device.Configuration.MemoryConfiguration.ToKernelMemoryArrange()); Device = device; State = new SystemStateMgr(); PerformanceState = new PerformanceState(); NfpDevices = new List <NfpDevice>(); // Note: This is not really correct, but with HLE of services, the only memory // region used that is used is Application, so we can use the other ones for anything. KMemoryRegionManager region = KernelContext.MemoryManager.MemoryRegions[(int)MemoryRegion.NvServices]; ulong hidPa = region.Address; ulong fontPa = region.Address + HidSize; ulong iirsPa = region.Address + HidSize + FontSize; ulong timePa = region.Address + HidSize + FontSize + IirsSize; ulong appletCaptureBufferPa = region.Address + HidSize + FontSize + IirsSize + TimeSize; KPageList hidPageList = new KPageList(); KPageList fontPageList = new KPageList(); KPageList iirsPageList = new KPageList(); KPageList timePageList = new KPageList(); KPageList appletCaptureBufferPageList = new KPageList(); hidPageList.AddRange(hidPa, HidSize / KPageTableBase.PageSize); fontPageList.AddRange(fontPa, FontSize / KPageTableBase.PageSize); iirsPageList.AddRange(iirsPa, IirsSize / KPageTableBase.PageSize); timePageList.AddRange(timePa, TimeSize / KPageTableBase.PageSize); appletCaptureBufferPageList.AddRange(appletCaptureBufferPa, AppletCaptureBufferSize / KPageTableBase.PageSize); var hidStorage = new SharedMemoryStorage(KernelContext, hidPageList); var fontStorage = new SharedMemoryStorage(KernelContext, fontPageList); var iirsStorage = new SharedMemoryStorage(KernelContext, iirsPageList); var timeStorage = new SharedMemoryStorage(KernelContext, timePageList); var appletCaptureBufferStorage = new SharedMemoryStorage(KernelContext, appletCaptureBufferPageList); HidStorage = hidStorage; HidSharedMem = new KSharedMemory(KernelContext, hidStorage, 0, 0, KMemoryPermission.Read); FontSharedMem = new KSharedMemory(KernelContext, fontStorage, 0, 0, KMemoryPermission.Read); IirsSharedMem = new KSharedMemory(KernelContext, iirsStorage, 0, 0, KMemoryPermission.Read); KSharedMemory timeSharedMemory = new KSharedMemory(KernelContext, timeStorage, 0, 0, KMemoryPermission.Read); TimeServiceManager.Instance.Initialize(device, this, timeSharedMemory, timeStorage, TimeSize); AppletCaptureBufferTransfer = new KTransferMemory(KernelContext, appletCaptureBufferStorage); AppletState = new AppletStateMgr(this); AppletState.SetFocus(true); Font = new SharedFontManager(device, fontStorage); VsyncEvent = new KEvent(KernelContext); DisplayResolutionChangeEvent = new KEvent(KernelContext); AccountManager = device.Configuration.AccountManager; ContentManager = device.Configuration.ContentManager; CaptureManager = new CaptureManager(device); // TODO: use set:sys (and get external clock source id from settings) // TODO: use "time!standard_steady_clock_rtc_update_interval_minutes" and implement a worker thread to be accurate. UInt128 clockSourceId = new UInt128(Guid.NewGuid().ToByteArray()); IRtcManager.GetExternalRtcValue(out ulong rtcValue); // We assume the rtc is system time. TimeSpanType systemTime = TimeSpanType.FromSeconds((long)rtcValue); // Configure and setup internal offset TimeSpanType internalOffset = TimeSpanType.FromSeconds(device.Configuration.SystemTimeOffset); TimeSpanType systemTimeOffset = new TimeSpanType(systemTime.NanoSeconds + internalOffset.NanoSeconds); if (systemTime.IsDaylightSavingTime() && !systemTimeOffset.IsDaylightSavingTime()) { internalOffset = internalOffset.AddSeconds(3600L); } else if (!systemTime.IsDaylightSavingTime() && systemTimeOffset.IsDaylightSavingTime()) { internalOffset = internalOffset.AddSeconds(-3600L); } internalOffset = new TimeSpanType(-internalOffset.NanoSeconds); // First init the standard steady clock TimeServiceManager.Instance.SetupStandardSteadyClock(null, clockSourceId, systemTime, internalOffset, TimeSpanType.Zero, false); TimeServiceManager.Instance.SetupStandardLocalSystemClock(null, new SystemClockContext(), systemTime.ToSeconds()); if (NxSettings.Settings.TryGetValue("time!standard_network_clock_sufficient_accuracy_minutes", out object standardNetworkClockSufficientAccuracyMinutes)) { TimeSpanType standardNetworkClockSufficientAccuracy = new TimeSpanType((int)standardNetworkClockSufficientAccuracyMinutes * 60000000000); // The network system clock needs a valid system clock, as such we setup this system clock using the local system clock. TimeServiceManager.Instance.StandardLocalSystemClock.GetClockContext(null, out SystemClockContext localSytemClockContext); TimeServiceManager.Instance.SetupStandardNetworkSystemClock(localSytemClockContext, standardNetworkClockSufficientAccuracy); } TimeServiceManager.Instance.SetupStandardUserSystemClock(null, false, SteadyClockTimePoint.GetRandom()); // FIXME: TimeZone shoud be init here but it's actually done in ContentManager TimeServiceManager.Instance.SetupEphemeralNetworkSystemClock(); DatabaseImpl.Instance.InitializeDatabase(device); HostSyncpoint = new NvHostSyncpt(device); SurfaceFlinger = new SurfaceFlinger(device); InitLibHacHorizon(); InitializeAudioRenderer(); }