61 {
62 opterr = 0;
63 int long_index = 0;
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}};
73
74
75 std::string cmd("");
76 for (int i = 0; i < argc; ++i) {
77 cmd += argv[i];
78 cmd += " ";
79 }
80 AINFO <<
"command: " << cmd;
81
82 if (1 == argc) {
84 exit(0);
85 }
86
87 do {
88 int opt =
89 getopt_long(argc, argv, short_opts.c_str(), long_opts, &long_index);
90 if (opt == -1) {
91 break;
92 }
93 switch (opt) {
94 case 'n':
97 AERROR <<
"Invalid numbers of reader. It should be grater than 0";
98 exit(-1);
99 }
100 break;
101 case 'c':
102#ifndef BASE_PROFILER_H_
103 AWARN <<
"gperftools not installed, ignore perf parameters";
104#endif
106 break;
107 case 'o':
109 break;
110 case 'H':
111#ifndef BASE_PROFILER_H_
112 AWARN <<
"gperftools not installed, ignore perf parameters";
113#endif
115 break;
116 case 'O':
118 break;
119 case 'h':
121 exit(0);
122 default:
123 break;
124 }
125 } while (true);
126
127 if (optind < argc) {
128 AINFO <<
"Found non-option ARGV-element \"" << argv[optind++] <<
"\"";
130 exit(1);
131 }
132}
std::string heapprofile_filename
std::string profile_filename