blob: c69bfa56541c5513b3df74c96e9162d67dbf63c8 [file] [log] [blame]
Ahmad Sharifae1714d2013-01-17 11:29:37 -08001// 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 Shariff5597f62013-04-25 12:25:41 -070013#include "random_selector.h"
14
Ahmad Sharifae1714d2013-01-17 11:29:37 -080015namespace debugd {
16
17class PerfTool {
18 public:
19 PerfTool();
20 ~PerfTool();
21
Ahmad Shariff5597f62013-04-25 12:25:41 -070022 // 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 Sharifae1714d2013-01-17 11:29:37 -080032 private:
Ahmad Shariff5597f62013-04-25 12:25:41 -070033 // 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 Sharifae1714d2013-01-17 11:29:37 -080037 DBus::Error& error,
38 std::string* data_string); // NOLINT
Ahmad Shariff5597f62013-04-25 12:25:41 -070039
40 RandomSelector random_selector_;
41
Ahmad Sharifae1714d2013-01-17 11:29:37 -080042 DISALLOW_COPY_AND_ASSIGN(PerfTool);
43};
44
45}; // namespace debugd
46
47#endif // !PERF_TOOL_H
48