72 const std::string short_opts =
"hs:t:q:d:T:co:HO:";
73 static const struct option long_opts[] = {
74 {
"help", no_argument,
nullptr,
'h'},
75 {
"message_size", required_argument,
nullptr,
's'},
76 {
"transport_freq", required_argument,
nullptr,
't'},
77 {
"qos_policy", required_argument,
nullptr,
'q'},
78 {
"data_type", required_argument,
nullptr,
'd'},
79 {
"time", required_argument,
nullptr,
'T'},
80 {
"cpuprofile", no_argument,
nullptr,
'c'},
81 {
"profile_filename", required_argument,
nullptr,
'o'},
82 {
"heapprofile", no_argument,
nullptr,
'H'},
83 {
"heapprofile_filename", required_argument,
nullptr,
'O'},
84 {NULL, no_argument,
nullptr, 0}};
88 for (
int i = 0; i < argc; ++i) {
92 AINFO <<
"command: " << cmd;
101 getopt_long(argc, argv, short_opts.c_str(), long_opts, &long_index);
109 arg = std::string(optarg);
110 switch (arg[arg.length()-1]) {
115 base_size = 1024 * 1024;
118 AERROR <<
"Invalid identifier. It should be 'K' or 'M' or 'B'";
121 message_size = std::stoi(arg.substr(0, arg.length()-1)) * base_size;
123 AERROR <<
"Invalid message size.";
130 AERROR <<
"Invalid transport frequency. It should greater than 0";
137 AERROR <<
"Invalid running time. It should greater than 0";
144 AERROR <<
"Invalid qos_policy. It should be 0 or 1";
149 data_type = std::stoi(std::string(optarg));
151 AERROR <<
"Invalid data_type. It should be 0 or 1";
156#ifndef BASE_PROFILER_H_
157 AWARN <<
"gperftools not installed, ignore perf parameters";
165#ifndef BASE_PROFILER_H_
166 AWARN <<
"gperftools not installed, ignore perf parameters";
182 AINFO <<
"Found non-option ARGV-element \"" << argv[optind++] <<
"\"";
188 AINFO <<
"-s and -t parameters must be specified";
194int main(
int argc,
char** argv) {
202 attrs.set_channel_name(
"/apollo/cyber/benchmark");
203 auto qos = attrs.mutable_qos_profile();
206 qos->set_reliability(
209 qos->set_reliability(
212 auto writer = node->CreateWriter<
245#ifdef BASE_PROFILER_H_
255std::vector<uint32_t> trans_vec;
257for (
int i = 0; i < num_of_instance; i++) {
258 trans_vec.push_back(rand());
263 while (send_msg < send_msg_total) {
264 auto trans_unit = std::make_shared<
268 for (
int i = 0; i < num_of_instance; i++) {
269 trans_vec[i] = base * i;
272 for (
int i = 0; i < num_of_instance; i++) {
273 *(uint32_t*)(data + i * 4) = base * i;
279 for (
int i = 0; i < num_of_instance; i++) {
280 trans_unit->add_data(trans_vec[i]);
284 writer->Write(trans_unit);
292#ifdef BASE_PROFILER_H_
297 HeapProfilerDump(
"Befor shutdown");