设为首页 加入收藏

TOP

POCO C++库学习和分析 -- 日期与时间 (十二)
2014-11-24 03:20:57 】 浏览:1136
Tags:POCO 学习 分析 --日期 时间
, s, dt, tzd);
Poco::Timestamp ts = dt.timestamp();
Poco::LocalDateTime ldt(tzd, dt);
bool ok = DateTimeParser::tryParse("2006-10-22", dt, tzd);
ok = DateTimeParser::tryParse("%e.%n.%Y", "22.10.2006", dt, tzd);
return 0;
}


8. Stopwatch类
Stopwatch用来测量时间差值,精度为微秒.下面是其定义:
[cpp]
class Foundation_API Stopwatch
/// A simple facility to measure time intervals
/// with microsecond resolution.
///
/// Note that Stopwatch is based on the Timestamp
/// class. Therefore, if during a Stopwatch run,
/// the system time is changed, the measured time
/// will not be correct.
{
public:
Stopwatch();
~Stopwatch();


void start();
/// Starts (or restarts) the stopwatch.

void stop();
/// Stops or pauses the stopwatch.

void reset();
/// Resets the stopwatch.

void restart();
/// Resets and starts the stopwatch.

Timestamp::TimeDiff elapsed() const;
/// Returns the elapsed time in microseconds
/// since the stopwatch started.

int elapsedSeconds() const;
/// Returns the number of seconds elapsed
/// since the stopwatch started.


static Timestamp::Timeva l resolution();
/// Returns the resolution of the stopwatch.


private:
Stopwatch(const Stopwatch&);
Stopwatch& operator = (const Stopwatch&);


Timestamp _start;
Timestamp::TimeDiff _elapsed;
bool _running;
};

class Foundation_API Stopwatch
/// A simple facility to measure time intervals
/// with microsecond resolution.
///
/// Note that Stopwatch is based on the Timestamp
/// class. Therefore, if during a Stopwatch run,
/// the system time is changed, the measured time
/// will not be correct.
{
public:
Stopwatch();
~Stopwatch();


void start();
/// Starts (or restarts) the stopwatch.

void stop();
/// Stops or pauses the stopwatch.

void reset();
/// Resets the stopwatch.

void restart();
/// Resets and starts the stopwatch.

Timestamp::TimeDiff elapsed() const;
/// Returns the elapsed time in microseconds
/// since the stopwatch started.

int elapsedSeconds() const;
/// Returns the number of seconds elapsed
/// since the stopwatch started.


static Timestamp::Timeva l resolution();
/// Returns the resolution of the stopwatch.


private:
Stopwatch(const Stopwatch&);
Stopwatch& operator = (const Stopwatch&);


Timestamp _start;
Timestamp::TimeDiff _elapsed;
bool _running;
};


首页 上一页 9 10 11 12 下一页 尾页 12/12/12
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇fzu 2035 Axial symmetry(几何) 下一篇BZOJ 2565 最长双回文串

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目