From: Timo Sirainen Date: Thu, 19 Nov 2015 12:46:54 +0000 (+0200) Subject: lib-fs: Added fs_stats_get_read/write_usecs() X-Git-Tag: 2.2.20.rc1~53 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3d2d3501736ff917f2de8a38f253c741c6f84e1e;p=thirdparty%2Fdovecot%2Fcore.git lib-fs: Added fs_stats_get_read/write_usecs() These can be easily used to sum up all the timings for read and write categories. --- diff --git a/src/lib-fs/fs-api.c b/src/lib-fs/fs-api.c index 43d74b1aed..2073becf61 100644 --- a/src/lib-fs/fs-api.c +++ b/src/lib-fs/fs-api.c @@ -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]); +} + diff --git a/src/lib-fs/fs-api.h b/src/lib-fs/fs-api.h index 5460d787bf..c21080386c 100644 --- a/src/lib-fs/fs-api.h +++ b/src/lib-fs/fs-api.h @@ -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