lin
2025-08-01 633231e833e21d5b8b1c00cb15aedb62b3b78e8f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
 
#ifndef CHROMIUMOS_WIDE_PROFILING_PERF_RECORDER_H_
#define CHROMIUMOS_WIDE_PROFILING_PERF_RECORDER_H_
 
#include <string>
#include <vector>
 
#include "base/macros.h"
 
#include "compat/string.h"
#include "perf_reader.h"
 
namespace quipper {
 
class PerfRecorder {
 public:
  PerfRecorder();
 
  // Mostly for testing.
  // Security critical: No user-provided strings should be used!
  explicit PerfRecorder(const std::vector<string>& perf_binary_command);
 
  // Runs the perf command specified in |perf_args| for |time_sec| seconds. The
  // output is returned as a serialized protobuf in |output_string|. The
  // protobuf format depends on the provided perf command.
  bool RunCommandAndGetSerializedOutput(const std::vector<string>& perf_args,
                                        const double time_sec,
                                        string* output_string);
 
  // The command prefix for running perf. e.g., "perf", or "/usr/bin/perf",
  // or perhaps {"sudo", "/usr/bin/perf"}.
  const std::vector<string>& perf_binary_command() const {
    return perf_binary_command_;
  }
 
 private:
  const std::vector<string> perf_binary_command_;
 
  DISALLOW_COPY_AND_ASSIGN(PerfRecorder);
};
 
}  // namespace quipper
 
#endif  // CHROMIUMOS_WIDE_PROFILING_PERF_RECORDER_H_