パフォーマンス情報を取得する

ここでは、GetPerformanceInfo関数を利用してパフォーマンス関連情報を取得するプログラムの書き方を説明したいと思います。 GetPerformanceInfoを利用するには、XPもしくはVista環境が必要です(2006年10月現在)。

サンプルコード

以下にサンプルを示します。


#include <stdio.h>

#include <windows.h>
#include <psapi.h>

int
main()
{
 PERFORMANCE_INFORMATION perf;
 DWORD sz;

 sz = sizeof(perf);
 GetPerformanceInfo(&perf, sz);

 printf("cb          %d\n", perf.cb);
 printf("CommitLimit %d\n", perf.CommitLimit);
 printf("CommitPeak  %d\n", perf.CommitPeak);
 printf("CommitTotal %d\n", perf.CommitTotal);
 printf("HandleCount %d\n", perf.HandleCount);
 printf("KernelNonpaged %d\n", perf.KernelNonpaged);	
 printf("KernelPaged %d\n", perf.KernelPaged);
 printf("KernelTotal %d\n", perf.KernelTotal);
 printf("PageSize    %d\n", perf.PageSize);
 printf("PhysicalAvailable %d\n", perf.PhysicalAvailable);
 printf("PhysicalTotal %d\n", perf.PhysicalTotal);
 printf("ProcessCount  %d\n", perf.ProcessCount);
 printf("SystemCache   %d\n", perf.SystemCache);
 printf("ThreadCount   %d\n", perf.ThreadCount);

 return 0;
}

PERFORMANCE_INFO

cb The size of this structure, in bytes.
CommitTotal The total number of pages committed by the system.
CommitLimit The current maximum number of page commits that can be performed by the system. This number can change if memory is added or deleted, or if pagefiles have grown, shrunk, or been added.
CommitPeak The maximum number of page commit totals that have occurred since the last reboot.
PhysicalTotal The total amount of physical memory, in pages.
PhysicalAvailable The amount of physical memory available to user processes, in pages.
SystemCache The total amount of system cache memory, in pages.
KernelTotal The total amount of the sum of the paged and nonpaged kernel pools, in pages.
KernelPaged The total amount of the paged kernel pool, in pages.
KernelNonpaged The total amount of the nonpaged kernel pool, in pages.
PageSize The size of a page, in bytes.
HandleCount The total number of open handles.
ProcessCount The total number of processes.
ThreadCount The total number of threads.

IPv6基礎検定

YouTubeチャンネルやってます!