blob: e612726528c233fd22646abbc06b482c78213368 [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
Alex Vakulenko262be3f2014-07-30 15:25:50 -07005#ifndef DEBUGD_SRC_PERF_TOOL_H_
6#define DEBUGD_SRC_PERF_TOOL_H_
Ahmad Sharifae1714d2013-01-17 11:29:37 -08007
8#include <string>
Ben Chana0011d82014-05-13 00:19:29 -07009#include <vector>
Ahmad Sharifae1714d2013-01-17 11:29:37 -080010
11#include <base/basictypes.h>
12#include <dbus-c++/dbus.h>
13
Alex Vakulenko262be3f2014-07-30 15:25:50 -070014#include "debugd/src/random_selector.h"
Ahmad Shariff5597f62013-04-25 12:25:41 -070015
Ahmad Sharifae1714d2013-01-17 11:29:37 -080016namespace debugd {
17
18class PerfTool {
19 public:
20 PerfTool();
21 ~PerfTool();
22
Ahmad Shariff5597f62013-04-25 12:25:41 -070023 // 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 Chana0011d82014-05-13 00:19:29 -070027 DBus::Error* error);
Ahmad Sharifae1714d2013-01-17 11:29:37 -080028 private:
Ahmad Shariff5597f62013-04-25 12:25:41 -070029 // 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 Chana0011d82014-05-13 00:19:29 -070033 DBus::Error* error,
34 std::string* data_string);
Ahmad Shariff5597f62013-04-25 12:25:41 -070035
36 RandomSelector random_selector_;
37
Ahmad Sharifae1714d2013-01-17 11:29:37 -080038 DISALLOW_COPY_AND_ASSIGN(PerfTool);
39};
40
Ben Chana0011d82014-05-13 00:19:29 -070041} // namespace debugd
Ahmad Sharifae1714d2013-01-17 11:29:37 -080042
Alex Vakulenko262be3f2014-07-30 15:25:50 -070043#endif // DEBUGD_SRC_PERF_TOOL_H_