Skip to content

Commit

Permalink
lib: Added timing_reset()
Browse files Browse the repository at this point in the history
  • Loading branch information
sirainen committed May 26, 2016
1 parent bde40af commit 801990c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/lib/test-timing.c
Expand Up @@ -71,6 +71,9 @@ void test_timing(void)
timing_add_usecs(t, test_inputs[i][j]);
test_timing_verify(t, test_inputs[i], j+1);
}
timing_reset(t);
test_assert(timing_get_count(t) == 0);
test_assert(timing_get_max(t) == 0);
timing_deinit(&t);
test_end();
}
Expand Down
5 changes: 5 additions & 0 deletions src/lib/timing.c
Expand Up @@ -27,6 +27,11 @@ void timing_deinit(struct timing **_timing)
i_free_and_null(*_timing);
}

void timing_reset(struct timing *timing)
{
memset(timing, 0, sizeof(*timing));
}

void timing_add_usecs(struct timing *timing, uint64_t usecs)
{
if (timing->count < TIMING_SUBSAMPLING_BUFFER) {
Expand Down
3 changes: 3 additions & 0 deletions src/lib/timing.h
Expand Up @@ -4,6 +4,9 @@
struct timing *timing_init(void);
void timing_deinit(struct timing **timing);

/* Reset all events. */
void timing_reset(struct timing *timing);

/* Add a new event that took the specified number of usecs. */
void timing_add_usecs(struct timing *timing, uint64_t usecs);

Expand Down

0 comments on commit 801990c

Please sign in to comment.