private void GetProcessDiagnostics() { try { ProcessDiagnosticInfo info = ProcessDiagnosticInfo.GetForCurrentProcess(); //ProcessCpuUsageReport cpuReport = info.CpuUsage.GetReport(); //TimeSpan kernelTime = cpuReport.KernelTime; //TimeSpan userTime = cpuReport.UserTime; ProcessMemoryUsageReport memoryReport = info.MemoryUsage.GetReport(); //ulong nonPagedPool = memoryReport.NonPagedPoolSizeInBytes; //ulong pagedPool = memoryReport.PagedPoolSizeInBytes; //ulong peakNonPagedPool = memoryReport.PeakNonPagedPoolSizeInBytes; //ulong peakPagedPool = memoryReport.PeakPagedPoolSizeInBytes; ulong virtualMemory = memoryReport.VirtualMemorySizeInBytes; ulong workingSet = memoryReport.WorkingSetSizeInBytes; //ulong peakVirtualMemory = memoryReport.PeakVirtualMemorySizeInBytes; //ulong peakWorkingSet = memoryReport.PeakWorkingSetSizeInBytes; //ulong pageFaults = memoryReport.PageFaultCount; //ulong pageFile = memoryReport.PageFileSizeInBytes; //ulong privatePages = memoryReport.PrivatePageCount; //ulong peakPageFile = memoryReport.PeakPageFileSizeInBytes; virtualMemoryText.Text = string.Format(CultureInfo.CurrentCulture, "{0:N}", (double)virtualMemory / MB); workingSetText.Text = string.Format(CultureInfo.CurrentCulture, "{0:N}", (double)workingSet / MB); } catch (Exception ex) { status.Log(ex.Message); } }
public ProcessInfoModel(ProcessDiagnosticInfo process) { ProcessCpuUsageReport cpuReport = process.CpuUsage.GetReport(); if (cpuReport != null) { TimeSpan cpuUsageTime = cpuReport.KernelTime + cpuReport.UserTime; CpuUsageTime = string.Format("{0:hh\\:mm\\:ss}", cpuUsageTime); } ProcessDiskUsageReport diskReport = process.DiskUsage.GetReport(); if (diskReport != null) { DiskBytesCount = diskReport.BytesReadCount + diskReport.BytesWrittenCount; } ProcessMemoryUsageReport memoryReport = process.MemoryUsage.GetReport(); if (memoryReport != null) { PageFileSize = memoryReport.PageFileSizeInBytes; WorkingSetSize = memoryReport.WorkingSetSizeInBytes; } ProcessId = process.ProcessId; ExeName = process.ExecutableFileName; }
private void DoMonitor(object state) { #if NETFX_CORE ProcessMemoryUsageReport report = CurrentProcess.GetReport(); if (monitorPagedMemory) { PagedMemory = (long)report.PageFileSizeInBytes; PeakPagedMemory = (long)report.PeakPageFileSizeInBytes; } if (monitorWorkingSet) { WorkingSet = (long)report.WorkingSetSizeInBytes; PeakWorkingSet = (long)report.PeakWorkingSetSizeInBytes; } if (monitorVirtualMemory) { VirtualMemory = (long)report.VirtualMemorySizeInBytes; PeakVirtualMemory = (long)report.PeakVirtualMemorySizeInBytes; } #else CurrentProcess.Refresh(); if (monitorPagedMemory) { PagedMemory = CurrentProcess.PagedMemorySize64; if (PagedMemory > PeakPagedMemory) { PeakPagedMemory = PagedMemory; } } if (monitorWorkingSet) { WorkingSet = CurrentProcess.WorkingSet64; if (WorkingSet > PeakWorkingSet) { PeakWorkingSet = WorkingSet; } } if (monitorVirtualMemory) { VirtualMemory = CurrentProcess.VirtualMemorySize64; if (VirtualMemory > PeakVirtualMemory) { PeakVirtualMemory = VirtualMemory; } } #endif }
private ulong GetProcessPrivateCommit(ProcessDiagnosticInfo process) { ulong privateCommit = 0; if (process.MemoryUsage != null) { ProcessMemoryUsageReport pmReport = process.MemoryUsage.GetReport(); if (pmReport != null) { privateCommit = pmReport.PageFileSizeInBytes; } } return(privateCommit); }
public async static void Update() { if (processes != null) { foreach (ProcessDiagnosticInfo process in processes) { string exeName = process.ExecutableFileName; string pid = process.ProcessId.ToString(); ProcessCpuUsageReport cpuReport = process.CpuUsage.GetReport(); TimeSpan userCpu = cpuReport.UserTime; TimeSpan kernelCpu = cpuReport.KernelTime; ProcessMemoryUsageReport memReport = process.MemoryUsage.GetReport(); ulong npp = memReport.NonPagedPoolSizeInBytes; ulong pp = memReport.PagedPoolSizeInBytes; ulong peakNpp = memReport.PeakNonPagedPoolSizeInBytes; //...etc ProcessDiskUsageReport diskReport = process.DiskUsage.GetReport(); long bytesRead = diskReport.BytesReadCount; long bytesWritten = diskReport.BytesWrittenCount; //...etc if (process.IsPackaged) { IList <AppDiagnosticInfo> diagnosticInfos = process.GetAppDiagnosticInfos(); if (diagnosticInfos != null && diagnosticInfos.Count > 0) { AppDiagnosticInfo diagnosticInfo = diagnosticInfos.FirstOrDefault(); if (diagnosticInfo != null) { IList <AppResourceGroupInfo> groups = diagnosticInfo.GetResourceGroups(); if (groups != null && groups.Count > 0) { AppResourceGroupInfo group = groups.FirstOrDefault(); if (group != null) { string name = diagnosticInfo.AppInfo.DisplayInfo.DisplayName; string description = diagnosticInfo.AppInfo.DisplayInfo.Description; BitmapImage bitmapImage = await GetLogoAsync(diagnosticInfo); AppResourceGroupStateReport stateReport = group.GetStateReport(); if (stateReport != null) { string executionStatus = stateReport.ExecutionState.ToString(); string energyStatus = stateReport.EnergyQuotaState.ToString(); } AppResourceGroupMemoryReport memoryReport = group.GetMemoryReport(); if (memoryReport != null) { AppMemoryUsageLevel level = memoryReport.CommitUsageLevel; ulong limit = memoryReport.CommitUsageLimit; ulong totalCommit = memoryReport.TotalCommitUsage; ulong privateCommit = memoryReport.PrivateCommitUsage; ulong sharedCommit = totalCommit - privateCommit; } } } } } } } } }
private AppInfoDetails CreateDetailsFromDiagnostics(AppRowInfo ari) { Debug.WriteLine("CreateDetailsFromDiagnostics: aumid={0}, name={1}", ari.Adi.AppInfo.AppUserModelId, ari.Adi.AppInfo.DisplayInfo.DisplayName); AppInfoDetails appDetails = null; try { // Create an AppInfoDetails from this AppRowInfo.AppDiagnosticInfo. IList <GroupInfoDetails> groupDetails = new List <GroupInfoDetails>(); IList <AppResourceGroupInfo> groups = ari.Adi.GetResourceGroups(); if (groups != null && groups.Count > 0) { foreach (AppResourceGroupInfo group in groups) { Debug.WriteLine("group Id: {0}", group.InstanceId); IList <ProcessInfoDetails> pDetails = new List <ProcessInfoDetails>(); IList <ProcessDiagnosticInfo> pInfos = group.GetProcessDiagnosticInfos(); if (pInfos != null && pInfos.Count > 0) { foreach (ProcessDiagnosticInfo pInfo in pInfos) { TimeSpan kernel = TimeSpan.Zero; TimeSpan user = TimeSpan.Zero; ulong npp = 0; ulong pp = 0; ulong pFault = 0; ulong pFile = 0; ulong pNpp = 0; ulong pPP = 0; ulong ppFile = 0; ulong pVirt = 0; ulong pWSet = 0; ulong ppc = 0; ulong vm = 0; ulong ws = 0; long br = 0; long bw = 0; long ob = 0; long oo = 0; long ro = 0; long wo = 0; ProcessCpuUsageReport pcReport = pInfo.CpuUsage.GetReport(); if (pcReport != null) { kernel = pcReport.KernelTime; user = pcReport.UserTime; } ProcessMemoryUsageReport pmReport = pInfo.MemoryUsage.GetReport(); if (pmReport != null) { npp = pmReport.NonPagedPoolSizeInBytes; pp = pmReport.PagedPoolSizeInBytes; pFault = pmReport.PageFaultCount; pFile = pmReport.PageFileSizeInBytes; pNpp = pmReport.PeakNonPagedPoolSizeInBytes; pPP = pmReport.PeakPagedPoolSizeInBytes; ppFile = pmReport.PeakPageFileSizeInBytes; pVirt = pmReport.PeakVirtualMemorySizeInBytes; pWSet = pmReport.PeakWorkingSetSizeInBytes; ppc = pmReport.PrivatePageCount; vm = pmReport.VirtualMemorySizeInBytes; ws = pmReport.WorkingSetSizeInBytes; } ProcessDiskUsageReport pdReport = pInfo.DiskUsage.GetReport(); if (pdReport != null) { br = pdReport.BytesReadCount; bw = pdReport.BytesWrittenCount; ob = pdReport.OtherBytesCount; oo = pdReport.OtherOperationCount; ro = pdReport.ReadOperationCount; wo = pdReport.WriteOperationCount; } ProcessInfoDetails pDetail = new ProcessInfoDetails( pInfo.ProcessId, pInfo.ExecutableFileName, pInfo.ProcessStartTime, kernel, user, npp, pp, pFault, pFile, pNpp, pPP, ppFile, pVirt, pWSet, ppc, vm, ws, br, bw, ob, oo, ro, wo); pDetails.Add(pDetail); } } AppMemoryUsageLevel usageLevel = AppMemoryUsageLevel.Low; ulong commitLimit = 0; ulong privateCommit = 0; ulong totalCommit = 0; AppResourceGroupExecutionState ex = AppResourceGroupExecutionState.Unknown; AppResourceGroupEnergyQuotaState eq = AppResourceGroupEnergyQuotaState.Unknown; AppResourceGroupMemoryReport mReport = group.GetMemoryReport(); AppResourceGroupStateReport sReport = group.GetStateReport(); IList <AppResourceGroupBackgroundTaskReport> bgReports = new List <AppResourceGroupBackgroundTaskReport>(); bgReports = group.GetBackgroundTaskReports(); if (mReport != null) { usageLevel = mReport.CommitUsageLevel; commitLimit = mReport.CommitUsageLimit; privateCommit = mReport.PrivateCommitUsage; totalCommit = mReport.TotalCommitUsage; } if (sReport != null) { ex = sReport.ExecutionState; eq = sReport.EnergyQuotaState; } GroupInfoDetails groupDetail = new GroupInfoDetails( group.InstanceId, group.IsShared, usageLevel, commitLimit, privateCommit, totalCommit, ex, eq, bgReports, pDetails); groupDetails.Add(groupDetail); } // We'll save time and get the cached Logo from the ARI, and get the rest of the data from the ADI. appDetails = new AppInfoDetails( ari.Logo, ari.Adi.AppInfo.AppUserModelId, ari.Adi.AppInfo.Id, ari.Adi.AppInfo.PackageFamilyName, ari.Adi.AppInfo.DisplayInfo.DisplayName, ari.Adi.AppInfo.DisplayInfo.Description, groupDetails); } } catch (Exception ex) { Debug.WriteLine(ex.ToString()); } return(appDetails); }
// public static List<Tuple<double, double, int>> HeightmapValues = new List<Tuple<double, double, int>>(); public static void Draw(CanvasAnimatedDrawEventArgs args) { Strings.Clear(); try { Strings.Add("Type: " + Mouse.TileTypeString); } catch (Exception e) { } Strings.Add("Max delta X: " + MaxDeltaX.ToString("F")); Strings.Add("Max delta Y: " + MaxDeltaY.ToString("F")); Strings.Add("Mouse: " + Mouse.CoordinatesString); Strings.Add("Mouse (chunk): " + Mouse.ChunkString); Strings.Add("Mouse (tile): " + Mouse.TileString); Strings.Add("Mouse (absolute tile): " + Mouse.AbsoluteTileString); Strings.Add("Mouse left: " + (Mouse.LeftButtonDown ? "DOWN" : "UP")); Strings.Add("Mouse right: " + (Mouse.RightButtonDown ? "DOWN" : "UP")); Strings.Add("Draw: " + LastDrawTime.ToString() + "ms"); Strings.Add("Draw mouse: " + LastDrawMouseTime.ToString() + "ms"); Strings.Add("Draw debug: " + LastDrawDebugTime.ToString() + "ms"); Strings.Add("Draw map: " + LastDrawMapTime.ToString() + "ms"); Strings.Add("Update: " + LastUpdateTime.ToString() + "ms"); Strings.Add("Debug update: " + LastDebugUpdateTime.ToString() + "ms"); Strings.Add("Full loop: " + LastFullLoopTime.ToString() + "ms"); Strings.Add("Full loop (max): " + MaxFullLoopTime.ToString() + "ms"); Strings.Add("Total frames: " + TotalFrames.ToString()); Strings.Add("Slow frames: " + SlowFrames.ToString()); Strings.Add("Camera offset: " + Camera.CoordinatesString()); Strings.Add("Camera offset (chunk): " + Camera.ChunkPositionString()); Strings.Add("Camera offset (tile): " + Camera.ChunkTilePositionString()); Strings.Add("Draw mode: " + Debug.DrawMode.ToString()); if (Map.DebugChunkCount > 0) { Strings.Add("Chunk count: " + TotalChunkCount.ToString()); Strings.Add("Chunks on screen: " + OnScreenChunkCount.ToString()); lock (DebugCollectionsLock) { Strings.Add("Average chunk load time: " + ChunkLoadTimes.Average().ToString("F") + "ms"); Strings.Add("Last chunk load time: " + ChunkLoadTimes.Last().ToString() + "ms"); Strings.Add("Average heightmap load time: " + HeightMapTimes.Average().ToString("F") + "ms"); Strings.Add("Last heightmap load time: " + HeightMapTimes.Last().ToString("F") + "ms"); } } ProcessMemoryUsageReport report = ProcessDiagnosticInfo.GetForCurrentProcess().MemoryUsage.GetReport(); Strings.Add("Working set: " + (report.WorkingSetSizeInBytes / 1000000).ToString() + "MB"); if (ChunkSizeMB != null) { Strings.Add(ChunkSizeMB); } //args.DrawingSession.DrawText("Folder: " + Windows.Storage.ApplicationData.Current.LocalFolder.Path, new Vector2(10, 10), Colors.White); int x = 1500; int y = 20; int width = 410; int height = (Strings.Count + 1) * 20; Color backgroundColor = Colors.CornflowerBlue; Color borderColor = Colors.White; args.DrawingSession.FillRectangle(new Windows.Foundation.Rect(x - 5, y - 5, width, height), backgroundColor); args.DrawingSession.DrawRoundedRectangle(new Windows.Foundation.Rect(x - 5, y - 5, width, height), 3, 3, borderColor); foreach (string str in Strings) { args.DrawingSession.DrawText(str, new Vector2(x, y), Colors.White); y += 20; } if (TimedStrings.Count > 0) { y += 50; height = (TimedStrings.Count + 1) * 20; args.DrawingSession.FillRectangle(new Windows.Foundation.Rect(x - 5, y - 5, width, height), backgroundColor); args.DrawingSession.DrawRoundedRectangle(new Windows.Foundation.Rect(x - 5, y - 5, width, height), 3, 3, borderColor); lock (Debug.DebugCollectionsLock) { foreach (TimedString str in TimedStrings) { str.Draw(args, new Vector2(x, y)); y += 20; } } } }