@@ -11,7 +11,8 @@ using Monitoring = o2::monitoring::MonitoringFactory;
1111
1212int main (int argc, char *argv[]) {
1313 int sleep = 1000000 ;
14- int count = 0 ;
14+ int count = 1 ;
15+ int measurements = 1 ;
1516
1617 std::random_device rd;
1718 std::mt19937 mt (rd ());
@@ -24,12 +25,13 @@ int main(int argc, char *argv[]) {
2425 (" sleep" , boost::program_options::value<int >(), " Thread sleep in microseconds" )
2526 (" url" , boost::program_options::value<std::string>()->required (), " URL to monitoring backend (or list of comma seperated URLs)" )
2627 (" id" , boost::program_options::value<std::string>(), " Instance ID" )
27- (" count" , boost::program_options::value<int >(), " Number of metric bunches (x3) " )
28+ (" count" , boost::program_options::value<int >(), " Number of loop cycles " )
2829 (" multiple" , boost::program_options::bool_switch ()->default_value (false ), " Sends multiple metrics per measurement" )
2930 (" vector" , boost::program_options::bool_switch ()->default_value (false ), " Sends vector of metrics" )
3031 (" monitor" , boost::program_options::bool_switch ()->default_value (false ), " Enabled process monitor" )
3132 (" buffer" , boost::program_options::value<int >(), " Creates buffr of given size" )
32- ;
33+ (" measurements" , boost::program_options::value<int >(), " Number of different measurements" )
34+ ;
3335
3436 boost::program_options::variables_map vm;
3537 boost::program_options::store (boost::program_options::parse_command_line (argc, argv, desc), vm);
@@ -43,44 +45,48 @@ int main(int argc, char *argv[]) {
4345 count = vm[" count" ].as <int >();
4446 }
4547
48+ if (vm.count (" measurements" )) {
49+ measurements = vm[" measurements" ].as <int >();
50+ }
51+
4652 auto monitoring = Monitoring::Get (vm[" url" ].as <std::string>());
4753 if (vm[" monitor" ].as <bool >()) {
4854 monitoring->enableProcessMonitoring (1 );
4955 }
50- int add = 0 ;
51- if (count != 0 ) {
52- count--;
53- add = 1 ;
54- }
55-
5656 if (vm[" multiple" ].as <bool >()) {
57- for (int i = 0 ; i <= count; i += add) {
58- monitoring->sendGrouped (" benchmarkMeasurement" ,{
59- {" string" + std::to_string (intDist (mt)), " stringMetric" },
60- {doubleDist (mt), " doubleMetric" },
61- {intDist (mt), " intMetric" }
62- });
63- std::this_thread::sleep_for (std::chrono::microseconds (sleep));
57+ for (int j = 1 ; j <= count; j++) {
58+ for (int i = 1 ; i <= measurements; i++) {
59+ monitoring->sendGrouped (" measurement" + std::to_string (i) ,{
60+ {doubleDist (mt), " doubleMetric" + std::to_string (i)},
61+ {intDist (mt), " intMetric" + std::to_string (i)}
62+ });
63+ std::this_thread::sleep_for (std::chrono::microseconds (sleep));
64+ }
65+ if (!vm.count (" count" )) j--;
6466 }
6567 } else if (vm[" vector" ].as <bool >()) {
66- for (int i = 0 ; i <= count; i += add) {
67- monitoring->send ({
68- {" string" + std::to_string (intDist (mt)), " stringMetric" },
69- {doubleDist (mt), " doubleMetric" },
70- {intDist (mt), " intMetricDebug" }
71- });
72- std::this_thread::sleep_for (std::chrono::microseconds (sleep));
68+ for (int j = 1 ; j <= count; j++) {
69+ for (int i = 1 ; i <= measurements; i++) {
70+ monitoring->send ({
71+ {doubleDist (mt), " doubleMetric" + std::to_string (i)},
72+ {intDist (mt), " intMetricDebug" + std::to_string (i)}
73+ });
74+ std::this_thread::sleep_for (std::chrono::microseconds (sleep));
75+ }
76+ if (!vm.count (" count" )) j--;
7377 }
7478 } else {
7579 if (vm.count (" buffer" )) {
7680 monitoring->enableBuffering (vm[" buffer" ].as <int >());
7781 }
78- for (int i = 0 ; i <= count; i += add) {
79- monitoring->send ({" string" + std::to_string (intDist (mt)), " stringMetric" });
80- monitoring->send ({doubleDist (mt), " doubleMetric" });
81- monitoring->send ({intDist (mt), " intMetric" });
82- monitoring->debug ({intDist (mt), " intMetricDebug" });
83- std::this_thread::sleep_for (std::chrono::microseconds (sleep));
82+ for (int j = 1 ; j <= count; j++) {
83+ for (int i = 1 ; i <= measurements; i++) {
84+ monitoring->send ({doubleDist (mt), " doubleMetric" + std::to_string (i)});
85+ monitoring->send ({intDist (mt), " intMetric" + std::to_string (i)});
86+ monitoring->debug ({intDist (mt), " intMetricDebug" + std::to_string (i)});
87+ std::this_thread::sleep_for (std::chrono::microseconds (sleep));
88+ }
89+ if (!vm.count (" count" )) j--;
8490 }
8591 }
8692}
0 commit comments