UNIX でプログラムの実行時間を計測するには,getrusage を使うのが基本ですが*1,Windows では使うことができません.代わりに Windows では QueryPerformanceCounter を使うが定番です*2. そこで下記のような関数を用意しておくと便利です. #ifdef WIN32 #include double get_usage_sec() { LARGE_INTEGER time, freq; QueryPerformanceCounter(&time); QueryPerformanceFrequency(&freq); return static_cast(time.QuadPart) / freq.QuadPart; } #else #include #include double get_usage_sec() { struct rusage