]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib: Added timing_reset()
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Wed, 25 May 2016 16:45:58 +0000 (19:45 +0300)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Wed, 25 May 2016 16:47:21 +0000 (19:47 +0300)
src/lib/test-timing.c
src/lib/timing.c
src/lib/timing.h

index e83df9f9bcbc96ef9c8ea6fc971b0286233d4090..467e47d3948fd4eb41a1f386f48b1ee5fcd0eec3 100644 (file)
@@ -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();
        }
index 18838c474e2dd0ca26ac65a8d44f26c7775ae9ff..9b8e2354fa227001db61988de55ad760e96c7191 100644 (file)
@@ -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) {
index 413dc2ed00191fe9bf8705f92feb677379611a6f..79536f9ed190ec2430869b3b82d60e3fa5be4c59 100644 (file)
@@ -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);