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