resetting GTimer
Submitted by Robert
Link to original bug (#434883)
Description
Hi there
GTimer seems to be missing a feature of resetting a stopped timer. The function g_timer_reset would be suitable for this purpose, but the documentation for it says it's useless. Besides, this function only works on started timers.
I would like to use GTimer for timing database communication. For this purpose, I'd like to create a new GTimer (best if it was stopped). Then I'll wrap my database query function so that it resumes the timer before a query is sent to database and stops it after response is received. Then the timer would be resumed on every successive query. So at the end of program, when we display the time that all database queries took, we have an easy nice grand total by just using g_timer_elapsed.
For now, the only thing I can do, is use g_timer_start on the first query, then g_timer_stop after it's done. Then every successive query would use g_timer_continue instead of start. But obviously, distinguishing a first from second and successive queries is quite awkward.
I think the best solution would be to have a new function (so as not to break backwards compatibility) like g_timer_zero, which would be able to reset a stopped timer. Also, a new version of g_timer_new that would NOT start the timer after allocating memory for it, would be nice.
Version: 2.13.x