プログラムの実行時間を計るには、QueryPerformanceCounter を使う。これには、CPU内蔵のカウンターを使っていると思われる。
using System.Runtime.InteropServices; する[DllImport("kernel32.dll")]
extern static short QueryPerformanceCounter(ref long x);
[DllImport("kernel32.dll")]
extern static short QueryPerformanceFrequency(ref long x); long ctr;
QueryPerformanceCounter(ref ctr);
で値がctrに入るので、2回実行するとその差が時間long f;
QueryPerformanceFrequency(ref f);
でわかる。1/f秒がカウンターの1に該当する。