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 | // Runs the perf tool for |duration_secs| seconds in systemwide mode and |
| 23 | // returns a protobuf containing the collected data. |
| 24 | std::vector<uint8> GetPerfData(const uint32_t& duration_secs, |
| 25 | DBus::Error& error); // NOLINT |
| 26 | |
| 27 | // Randomly runs the perf tool in various modes and collects various events |
| 28 | // for |duration_secs| seconds and returns a protobuf containing the collected |
| 29 | // data. |
| 30 | std::vector<uint8> GetRichPerfData(const uint32_t& duration_secs, |
| 31 | DBus::Error& error); // NOLINT |
Ahmad Sharif | ae1714d | 2013-01-17 11:29:37 -0800 | [diff] [blame] | 32 | private: |
Ahmad Sharif | f5597f6 | 2013-04-25 12:25:41 -0700 | [diff] [blame^] | 33 | // Helper function that runs perf for a given |duration_secs| returning the |
| 34 | // collected data in |data_string|. |
| 35 | void GetPerfDataHelper(const uint32_t& duration_secs, |
| 36 | const std::string& perf_command_line, |
Ahmad Sharif | ae1714d | 2013-01-17 11:29:37 -0800 | [diff] [blame] | 37 | DBus::Error& error, |
| 38 | std::string* data_string); // NOLINT |
Ahmad Sharif | f5597f6 | 2013-04-25 12:25:41 -0700 | [diff] [blame^] | 39 | |
| 40 | RandomSelector random_selector_; |
| 41 | |
Ahmad Sharif | ae1714d | 2013-01-17 11:29:37 -0800 | [diff] [blame] | 42 | DISALLOW_COPY_AND_ASSIGN(PerfTool); |
| 43 | }; |
| 44 | |
| 45 | }; // namespace debugd |
| 46 | |
| 47 | #endif // !PERF_TOOL_H |
| 48 | |