GTimer只是个计时器

来源:互联网 发布:容祖儿密友知乎 编辑:程序博客网 时间:2024/04/29 13:04
GTimer只是个计时器,当您需要量测两个执行时间点的间隔时就可以使用,例如程序执行的开始与结束时间,您可以使用g_timer_new()建立一个新的GTimer,若不再需要时则使用g_timer_destroy()加以销毁。


在g_timer_new()之后,会自动启动计时,您也可以使用g_timer_start()再度启动计时,并于g_timer_elapsed()被调用时,传回自启动后的时间。在使用g_timer_end()结束时间之后,您可以使用g_timer_continue()重新继续GTimer的计时。

所以不能用来当定时器使用。

Timers

Timers — keep track of elapsed time

 

Synopsis

#include <glib.h>                    GTimer;GTimer *            g_timer_new                         (void);void                g_timer_start                       (GTimer *timer);void                g_timer_stop                        (GTimer *timer);void                g_timer_continue                    (GTimer *timer);gdouble             g_timer_elapsed                     (GTimer *timer,                                                         gulong *microseconds);void                g_timer_reset                       (GTimer *timer);void                g_timer_destroy                     (GTimer *timer);

Description

GTimer records a start time, and counts microseconds elapsed since that time. This is done somewhat differently on different platforms, and can be tricky to get exactly right, so GTimer provides a portable/convenient interface.