1 // Copyright 2015 The Chromium OS Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef CHROMIUMOS_WIDE_PROFILING_PERF_STAT_PARSER_H_ 6 #define CHROMIUMOS_WIDE_PROFILING_PERF_STAT_PARSER_H_ 7 8 #include <string> 9 10 #include "base/macros.h" 11 12 #include "compat/proto.h" 13 #include "compat/string.h" 14 15 namespace quipper { 16 17 // These functions parse the contents at |path| or of |data| into a 18 // PerfStatProto. Return true if at least one line of data was inserted into 19 // |proto|. Otherwise return false; 20 // Both functions below assume perf stat output is in the form: 21 // "event: 123 123 123\n" 22 // "event2: 123 123 123\n" 23 // "..." 24 // "1.234 seconds time elapsed" 25 bool ParsePerfStatFileToProto(const string& path, PerfStatProto* proto); 26 bool ParsePerfStatOutputToProto(const string& data, PerfStatProto* proto); 27 28 // This function assumes that |str| is of the form "1234.1234567" and returns 29 // false otherwise. This function does not accept negatives (e.g. "-12.23"). 30 bool SecondsStringToMillisecondsUint64(const string& str, uint64_t* out); 31 32 } // namespace quipper 33 34 #endif // CHROMIUMOS_WIDE_PROFILING_PERF_STAT_PARSER_H_ 35