Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1456)

Unified Diff: base/process/internal_linux.cc

Issue 2715583002: base/process: Use /proc/self/stat to read startup time. (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: base/process/internal_linux.cc
diff --git a/base/process/internal_linux.cc b/base/process/internal_linux.cc
index e9ed641dc02909c4b4edea18be5508c630c5527f..47d113ad77268addeb47c4f4e443dd5b7690bdd8 100644
--- a/base/process/internal_linux.cc
+++ b/base/process/internal_linux.cc
@@ -133,6 +133,18 @@ size_t GetProcStatsFieldAsSizeT(const std::vector<std::string>& proc_stats,
return StringToSizeT(proc_stats[field_num], &value) ? value : 0;
}
+int64_t ReadProcStatsAndGetFieldAsInt64(const std::string& pid,
+ ProcStatsFields field_num) {
+ std::string stats_data;
+ FilePath stat_file = FilePath(kProcDir).Append(pid).Append(kStatFile);
+ if (!ReadProcFile(stat_file, &stats_data))
+ return 0;
+ std::vector<std::string> proc_stats;
jln (very slow on Chromium) 2017/02/22 22:37:15 A little too much code duplication here. Perhaps r
Daniele Castagna 2017/02/23 18:04:10 Done.
+ if (!ParseProcStats(stats_data, &proc_stats))
+ return 0;
+ return GetProcStatsFieldAsInt64(proc_stats, field_num);
+}
+
int64_t ReadProcStatsAndGetFieldAsInt64(pid_t pid, ProcStatsFields field_num) {
std::string stats_data;
if (!ReadProcStats(pid, &stats_data))

Powered by Google App Engine
This is Rietveld 408576698