読者です 読者をやめる 読者になる 読者になる

Haruyuki Mohri

毛利春幸のブログです。

high-resolution stopwatch implementation. in C++Builder

TStopwatch is high-resolution stopwatch.

This is present in the version of the old. Unfortunately, I did not know.

The header, it will include.

#include <System.Diagnostics.hpp>

Implementation

 TStopwatch stopwatch = TStopwatch::Create();
    stopwatch.Start();
    Sleep(301);
    stopwatch.Stop();
    ShowMessage(
        String().sprintf(L"%d", stopwatch.ElapsedMilliseconds));

TStopwatch is delphi record.

Although I tried to new in "C++", it can be executed.

 TStopwatch* stopwatch = new TStopwatch();//::Create();
    stopwatch->Create();
    stopwatch->Start();
    Sleep(301);
    stopwatch->Stop();
    ShowMessage(
        String().sprintf(L"%d", stopwatch->ElapsedMilliseconds));
    delete stopwatch;

But, Because it is feel free types, "new" is not needed.

f:id:mojeld:20150825113641p:plain

System.Diagnostics.TStopwatch - RAD Studio API Documentation