Add metrics for time elapsed in base::File::Flush().
According to a synthetic benchmark quoted in issue 469071, fsync() can take up to 700ms if the system is under heavy I/O load. This CL will bring in real-world data that we may use to prioritize efforts on reducing fsync() use.
BUG=473337
Review URL: https://codereview.chromium.org/1044463002
Cr-Commit-Position: refs/heads/master@{#323722}
CrOS-Libchrome-Original-Commit: 0ac3148f2099b47e41f08c2318a89ca418858664
diff --git a/base/files/file.cc b/base/files/file.cc
index a997074..86fdbc9 100644
--- a/base/files/file.cc
+++ b/base/files/file.cc
@@ -4,6 +4,8 @@
#include "base/files/file.h"
#include "base/files/file_path.h"
+#include "base/metrics/histogram.h"
+#include "base/timer/elapsed_timer.h"
#if defined(OS_POSIX)
#include "base/files/file_posix_hooks_internal.h"
@@ -134,4 +136,11 @@
return "";
}
+bool File::Flush() {
+ ElapsedTimer timer;
+ bool return_value = DoFlush();
+ UMA_HISTOGRAM_TIMES("PlatformFile.FlushTime", timer.Elapsed());
+ return return_value;
+}
+
} // namespace base