22#include "cyber/benchmark/benchmark_msg.pb.h"
25#if __has_include("gperftools/profiler.h")
26#include "gperftools/heap-profiler.h"
27#include "gperftools/malloc_extension.h"
28#include "gperftools/profiler.h"
44 <<
" -h, --help: help information \n"
45 <<
" -n, --nums_of_reader=nums_of_reader: numbers of reader, "
46 "default value is 1\n"
47 <<
" -c, --cpuprofile: enable gperftools cpu profile\n"
48 <<
" -o, --profile_filename=filename: the filename to dump the "
49 "profile to, default value is cyber_benchmark_writer_cpu.prof. "
50 "Only work with -c option\n"
51 <<
" -H, --heapprofile: enable gperftools heap profile\n"
52 <<
" -O, --heapprofile_filename=filename: the filename "
53 " to dump the profile to, default value is "
54 "cyber_benchmark_writer_mem.prof. Only work with -H option\n"
64 const std::string short_opts =
"hn:co:HO:";
65 static const struct option long_opts[] = {
66 {
"help", no_argument,
nullptr,
'h'},
67 {
"nums_of_reader", required_argument,
nullptr,
'n'},
68 {
"cpuprofile", no_argument,
nullptr,
'c'},
69 {
"profile_filename", required_argument,
nullptr,
'o'},
70 {
"heapprofile", no_argument,
nullptr,
'H'},
71 {
"heapprofile_filename", required_argument,
nullptr,
'O'},
72 {NULL, no_argument,
nullptr, 0}};
76 for (
int i = 0; i < argc; ++i) {
80 AINFO <<
"command: " << cmd;
89 getopt_long(argc, argv, short_opts.c_str(), long_opts, &long_index);
97 AERROR <<
"Invalid numbers of reader. It should be grater than 0";
102#ifndef BASE_PROFILER_H_
103 AWARN <<
"gperftools not installed, ignore perf parameters";
111#ifndef BASE_PROFILER_H_
112 AWARN <<
"gperftools not installed, ignore perf parameters";
128 AINFO <<
"Found non-option ARGV-element \"" << argv[optind++] <<
"\"";
134int main(
int argc,
char** argv) {
136 google::SetCommandLineOption(
"bvar_dump_interval",
"1");
144 std::vector<std::shared_ptr<apollo::cyber::Reader<BenchmarkMsg>>> vec;
149 vec.push_back(std::move(node->CreateReader<
BenchmarkMsg>(
150 reader_config, [](
const std::shared_ptr<BenchmarkMsg> m) {})));
154#ifdef BASE_PROFILER_H_
167#ifdef BASE_PROFILER_H_
172 HeapProfilerDump(
"Befor shutdown");
int main(int argc, char **argv)
void GetOptions(const int argc, char *const argv[])
std::string heapprofile_filename
std::string profile_filename
bool Init(const char *binary_name, const std::string &dag_info)
std::unique_ptr< Node > CreateNode(const std::string &node_name, const std::string &name_space)
proto::QosProfile qos_profile