mirror of
https://github.com/libgit2/libgit2.git
synced 2026-01-25 02:56:17 +00:00
`git__timer` is now `git_time_monotonic`, and returns milliseconds since an arbitrary epoch. Using a floating point to store the number of seconds elapsed was clever, as it better supports the wide range of precision from the different monotonic clocks of different systems. But we're a version control system, not a real-time clock. Milliseconds is a good enough precision for our work _and_ it's the units that system calls like `poll` take and that our users interact with. Make `git_time_monotonic` return the monotonically increasing number of milliseconds "ticked" since some arbitrary epoch.
36 lines
792 B
C
36 lines
792 B
C
#ifndef __CLAR_LIBGIT2_TIMER__
|
|
#define __CLAR_LIBGIT2_TIMER__
|
|
|
|
struct cl_perf_timer
|
|
{
|
|
/* cumulative running time across all start..stop intervals */
|
|
uint64_t sum;
|
|
|
|
/* value of last start..stop interval */
|
|
uint64_t last;
|
|
|
|
/* clock value at start */
|
|
uint64_t time_started;
|
|
};
|
|
|
|
#define CL_PERF_TIMER_INIT {0}
|
|
|
|
typedef struct cl_perf_timer cl_perf_timer;
|
|
|
|
void cl_perf_timer__init(cl_perf_timer *t);
|
|
void cl_perf_timer__start(cl_perf_timer *t);
|
|
void cl_perf_timer__stop(cl_perf_timer *t);
|
|
|
|
/**
|
|
* return value of last start..stop interval in seconds.
|
|
*/
|
|
uint64_t cl_perf_timer__last(const cl_perf_timer *t);
|
|
|
|
/**
|
|
* return cumulative running time across all start..stop
|
|
* intervals in seconds.
|
|
*/
|
|
uint64_t cl_perf_timer__sum(const cl_perf_timer *t);
|
|
|
|
#endif /* __CLAR_LIBGIT2_TIMER__ */
|