Skip to content
Search

Boost:Timer

lastmod 2015-06-23created 2015-06-232 edits

Example

How to measure elapsed time using a boost::timer object is shown below.

The following explains "how to measure elapsed time (in milliseconds) using a boost::timer object".

#include "boost/timer.hpp"
#include <iostream>
#include <windows.h>

int main(int argc, char **argv)
{
    boost::timer t;
    Sleep(300);
    std::cout << "after 300 ms : " << t.elapsed() << std::endl; // 경과된 시간 조회.
    Sleep(400);
    std::cout << "after 400 ms : " << t.elapsed() << std::endl; // 누적된 경과 시간.
    std::cout << "restart timer .." << std::endl;
    t.restart(); // 경과된 시간 초기화.
    Sleep(500);
    std::cout << "after 500 ms : " << t.elapsed() << std::endl; // 경과된 시간 조회.
    return 0;
}

Favorite site