Ahmad Sharif | ae1714d | 2013-01-17 11:29:37 -0800 | [diff] [blame] | 1 | // Copyright (c) 2012 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 | |
Alex Vakulenko | 262be3f | 2014-07-30 15:25:50 -0700 | [diff] [blame] | 5 | #ifndef DEBUGD_SRC_PERF_TOOL_H_ |
| 6 | #define DEBUGD_SRC_PERF_TOOL_H_ |
Ahmad Sharif | ae1714d | 2013-01-17 11:29:37 -0800 | [diff] [blame] | 7 | |
Ben Chan | 49d264c | 2014-08-06 17:38:16 -0700 | [diff] [blame] | 8 | #include <stdint.h> |
David Sharp | 0001e25 | 2015-08-27 15:59:31 -0700 | [diff] [blame] | 9 | #include <sys/utsname.h> |
Ben Chan | 49d264c | 2014-08-06 17:38:16 -0700 | [diff] [blame] | 10 | |
Ahmad Sharif | ae1714d | 2013-01-17 11:29:37 -0800 | [diff] [blame] | 11 | #include <string> |
Ben Chan | a0011d8 | 2014-05-13 00:19:29 -0700 | [diff] [blame] | 12 | #include <vector> |
Ahmad Sharif | ae1714d | 2013-01-17 11:29:37 -0800 | [diff] [blame] | 13 | |
Eric Caruso | 0b24188 | 2018-04-04 13:43:46 -0700 | [diff] [blame^] | 14 | #include <base/files/scoped_file.h> |
Ben Chan | 657bed8 | 2014-09-02 20:40:51 -0700 | [diff] [blame] | 15 | #include <base/macros.h> |
Eric Caruso | cc7106c | 2017-04-27 14:22:42 -0700 | [diff] [blame] | 16 | #include <brillo/errors/error.h> |
Ahmad Sharif | ae1714d | 2013-01-17 11:29:37 -0800 | [diff] [blame] | 17 | |
| 18 | namespace debugd { |
| 19 | |
| 20 | class PerfTool { |
| 21 | public: |
| 22 | PerfTool(); |
Ben Chan | 78f8953 | 2014-08-29 09:35:09 -0700 | [diff] [blame] | 23 | ~PerfTool() = default; |
Ahmad Sharif | ae1714d | 2013-01-17 11:29:37 -0800 | [diff] [blame] | 24 | |
David Sharp | 4324e9a | 2015-08-05 14:23:41 -0700 | [diff] [blame] | 25 | // Runs the perf tool with the request command for |duration_secs| seconds |
| 26 | // and returns either a perf_data or perf_stat protobuf in serialized form. |
Eric Caruso | 56eacb2 | 2017-08-04 11:00:37 -0700 | [diff] [blame] | 27 | bool GetPerfOutput(uint32_t duration_secs, |
| 28 | const std::vector<std::string>& perf_args, |
| 29 | std::vector<uint8_t>* perf_data, |
| 30 | std::vector<uint8_t>* perf_stat, |
| 31 | int32_t* status, |
| 32 | brillo::ErrorPtr* error); |
Simon Que | 795327b | 2015-03-16 17:42:35 -0700 | [diff] [blame] | 33 | |
David Sharp | 16d3565 | 2016-04-05 17:20:08 -0700 | [diff] [blame] | 34 | // Runs the perf tool with the request command for |duration_secs| seconds |
| 35 | // and returns either a perf_data or perf_stat protobuf in serialized form |
| 36 | // over the passed stdout_fd file descriptor, or nothing if there was an |
| 37 | // error. |
Eric Caruso | 56eacb2 | 2017-08-04 11:00:37 -0700 | [diff] [blame] | 38 | bool GetPerfOutputFd(uint32_t duration_secs, |
David Sharp | 16d3565 | 2016-04-05 17:20:08 -0700 | [diff] [blame] | 39 | const std::vector<std::string>& perf_args, |
Eric Caruso | 0b24188 | 2018-04-04 13:43:46 -0700 | [diff] [blame^] | 40 | const base::ScopedFD& stdout_fd, |
Eric Caruso | cc7106c | 2017-04-27 14:22:42 -0700 | [diff] [blame] | 41 | brillo::ErrorPtr* error); |
David Sharp | 16d3565 | 2016-04-05 17:20:08 -0700 | [diff] [blame] | 42 | |
Ahmad Sharif | ae1714d | 2013-01-17 11:29:37 -0800 | [diff] [blame] | 43 | private: |
Ahmad Sharif | ae1714d | 2013-01-17 11:29:37 -0800 | [diff] [blame] | 44 | DISALLOW_COPY_AND_ASSIGN(PerfTool); |
| 45 | }; |
| 46 | |
Ben Chan | a0011d8 | 2014-05-13 00:19:29 -0700 | [diff] [blame] | 47 | } // namespace debugd |
Ahmad Sharif | ae1714d | 2013-01-17 11:29:37 -0800 | [diff] [blame] | 48 | |
Alex Vakulenko | 262be3f | 2014-07-30 15:25:50 -0700 | [diff] [blame] | 49 | #endif // DEBUGD_SRC_PERF_TOOL_H_ |