blob: a703c5b280f55858f0491e23f770f8c42ed1300c [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
Ben Chan49d264c2014-08-06 17:38:16 -07008#include <stdint.h>
9
Ahmad Sharifae1714d2013-01-17 11:29:37 -080010#include <string>
Ben Chana0011d82014-05-13 00:19:29 -070011#include <vector>
Ahmad Sharifae1714d2013-01-17 11:29:37 -080012
13#include <base/basictypes.h>
14#include <dbus-c++/dbus.h>
15
Alex Vakulenko262be3f2014-07-30 15:25:50 -070016#include "debugd/src/random_selector.h"
Ahmad Shariff5597f62013-04-25 12:25:41 -070017
Ahmad Sharifae1714d2013-01-17 11:29:37 -080018namespace debugd {
19
20class PerfTool {
21 public:
22 PerfTool();
Ben Chan78f89532014-08-29 09:35:09 -070023 ~PerfTool() = default;
Ahmad Sharifae1714d2013-01-17 11:29:37 -080024
Ahmad Shariff5597f62013-04-25 12:25:41 -070025 // Randomly runs the perf tool in various modes and collects various events
26 // for |duration_secs| seconds and returns a protobuf containing the collected
27 // data.
Ben Chan49d264c2014-08-06 17:38:16 -070028 std::vector<uint8_t> GetRichPerfData(const uint32_t& duration_secs,
29 DBus::Error* error);
Ahmad Sharifae1714d2013-01-17 11:29:37 -080030 private:
Ahmad Shariff5597f62013-04-25 12:25:41 -070031 // Helper function that runs perf for a given |duration_secs| returning the
32 // collected data in |data_string|.
33 void GetPerfDataHelper(const uint32_t& duration_secs,
34 const std::string& perf_command_line,
Ben Chana0011d82014-05-13 00:19:29 -070035 DBus::Error* error,
36 std::string* data_string);
Ahmad Shariff5597f62013-04-25 12:25:41 -070037
38 RandomSelector random_selector_;
39
Ahmad Sharifae1714d2013-01-17 11:29:37 -080040 DISALLOW_COPY_AND_ASSIGN(PerfTool);
41};
42
Ben Chana0011d82014-05-13 00:19:29 -070043} // namespace debugd
Ahmad Sharifae1714d2013-01-17 11:29:37 -080044
Alex Vakulenko262be3f2014-07-30 15:25:50 -070045#endif // DEBUGD_SRC_PERF_TOOL_H_