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> |
| 9 | |
Ahmad Sharif | ae1714d | 2013-01-17 11:29:37 -0800 | [diff] [blame] | 10 | #include <string> |
Ben Chan | a0011d8 | 2014-05-13 00:19:29 -0700 | [diff] [blame] | 11 | #include <vector> |
Ahmad Sharif | ae1714d | 2013-01-17 11:29:37 -0800 | [diff] [blame] | 12 | |
| 13 | #include <base/basictypes.h> |
| 14 | #include <dbus-c++/dbus.h> |
| 15 | |
Alex Vakulenko | 262be3f | 2014-07-30 15:25:50 -0700 | [diff] [blame] | 16 | #include "debugd/src/random_selector.h" |
Ahmad Sharif | f5597f6 | 2013-04-25 12:25:41 -0700 | [diff] [blame] | 17 | |
Ahmad Sharif | ae1714d | 2013-01-17 11:29:37 -0800 | [diff] [blame] | 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 | |
Ahmad Sharif | f5597f6 | 2013-04-25 12:25:41 -0700 | [diff] [blame] | 25 | // Randomly runs the perf tool in various modes and collects various events |
| 26 | // for |duration_secs| seconds and returns a protobuf containing the collected |
| 27 | // data. |
Ben Chan | 49d264c | 2014-08-06 17:38:16 -0700 | [diff] [blame] | 28 | std::vector<uint8_t> GetRichPerfData(const uint32_t& duration_secs, |
| 29 | DBus::Error* error); |
Ahmad Sharif | ae1714d | 2013-01-17 11:29:37 -0800 | [diff] [blame] | 30 | private: |
Ahmad Sharif | f5597f6 | 2013-04-25 12:25:41 -0700 | [diff] [blame] | 31 | // Helper function that runs perf for a given |duration_secs| returning the |
| 32 | // collected data in |data_string|. |
| 33 | void GetPerfDataHelper(const uint32_t& duration_secs, |
| 34 | const std::string& perf_command_line, |
Ben Chan | a0011d8 | 2014-05-13 00:19:29 -0700 | [diff] [blame] | 35 | DBus::Error* error, |
| 36 | std::string* data_string); |
Ahmad Sharif | f5597f6 | 2013-04-25 12:25:41 -0700 | [diff] [blame] | 37 | |
| 38 | RandomSelector random_selector_; |
| 39 | |
Ahmad Sharif | ae1714d | 2013-01-17 11:29:37 -0800 | [diff] [blame] | 40 | DISALLOW_COPY_AND_ASSIGN(PerfTool); |
| 41 | }; |
| 42 | |
Ben Chan | a0011d8 | 2014-05-13 00:19:29 -0700 | [diff] [blame] | 43 | } // namespace debugd |
Ahmad Sharif | ae1714d | 2013-01-17 11:29:37 -0800 | [diff] [blame] | 44 | |
Alex Vakulenko | 262be3f | 2014-07-30 15:25:50 -0700 | [diff] [blame] | 45 | #endif // DEBUGD_SRC_PERF_TOOL_H_ |