' get time (second). use mmsystem ' mmsystem(マルチメディア関連ライブラリ)を利用して、 ' Windows上のタイマー精度を一時的に 1msec に向上させる。 ' 処理が終わったら本来のタイマー精度に戻すこと。 ' mmsystemを利用 #include "windows.bi" #include "win/mmsystem.bi" Dim As Double start_time, prev_time, now_time, diff_time, one_frame Dim frame_count As Integer ' タイマー精度を1msecに向上 timeBeginPeriod(1) ' 1フレームあたりの本来の時間 one_frame = 1.0 / 60.0 frame_count = 0 start_time = Timer prev_time = start_time ' 1秒間ループさせる Do now_time = Timer diff_time = now_time - prev_time prev_time = now_time Print "Diff: "; diff_time If Timer < (now_time + one_frame) Then ' 本来のフレーム時間がまだ経過してないので sleep させる sleep ((now_time + one_frame) - Timer) * 1000.0 End If frame_count += 1 Loop until (now_time - start_time) >= 1.0 ' タイマー精度を本来のスペックに戻す timeEndPeriod(1) Print "frame_count=" & frame_count Print "Push Any Key" sleep