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