]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-fs: Added fs_stats_get_read/write_usecs()
authorTimo Sirainen <tss@iki.fi>
Thu, 19 Nov 2015 12:46:54 +0000 (14:46 +0200)
committerTimo Sirainen <tss@iki.fi>
Thu, 19 Nov 2015 12:46:54 +0000 (14:46 +0200)
These can be easily used to sum up all the timings for read and write
categories.

src/lib-fs/fs-api.c
src/lib-fs/fs-api.h

index 43d74b1aed8902eb4a4dc9e6e6c7da033d296892..2073becf610e1ae19dc0281d405023c42312693f 100644 (file)
@@ -987,3 +987,21 @@ void fs_set_error_async(struct fs *fs)
        fs_set_error(fs, "Asynchronous operation in progress");
        errno = EAGAIN;
 }
+
+uint64_t fs_stats_get_read_usecs(const struct fs_stats *stats)
+{
+       return timing_get_sum(stats->timings[FS_OP_METADATA]) +
+               timing_get_sum(stats->timings[FS_OP_PREFETCH]) +
+               timing_get_sum(stats->timings[FS_OP_READ]) +
+               timing_get_sum(stats->timings[FS_OP_EXISTS]) +
+               timing_get_sum(stats->timings[FS_OP_STAT]) +
+               timing_get_sum(stats->timings[FS_OP_ITER]);
+}
+
+uint64_t fs_stats_get_write_usecs(const struct fs_stats *stats)
+{
+       return timing_get_sum(stats->timings[FS_OP_WRITE]) +
+               timing_get_sum(stats->timings[FS_OP_COPY]) +
+               timing_get_sum(stats->timings[FS_OP_DELETE]);
+}
+
index 5460d787bfc149b7a5a056031da1125a1ace8a99..c21080386c2d845d0ccde710a43fce9ab65d1a08 100644 (file)
@@ -333,4 +333,8 @@ bool fs_iter_have_more(struct fs_iter *iter);
    filesystem whose stats you want to see. */
 const struct fs_stats *fs_get_stats(struct fs *fs);
 
+/* Helper functions to count number of usecs for read/write operations. */
+uint64_t fs_stats_get_read_usecs(const struct fs_stats *stats);
+uint64_t fs_stats_get_write_usecs(const struct fs_stats *stats);
+
 #endif