19std::shared_ptr<ROOT::RWebWindow> window;
22bool window_terminated =
false;
24bool batch_mode =
false;
25int current_counter = 0;
27auto start_tm = std::chrono::high_resolution_clock::now();
28auto firstmsg_tm = start_tm;
29auto stop_tm = start_tm;
30std::string round_trip =
"<not defined>";
32void ProcessData(
unsigned connid,
const std::string &arg)
34 if (arg.find(
"PING:") == 0) {
35 window->Send(connid, arg);
36 }
else if (arg ==
"first") {
38 firstmsg_tm = std::chrono::high_resolution_clock::now();
39 std::vector<std::string> clients;
42 for (
int n = 1;
n < num_clients; ++
n)
43 clients.emplace_back(
".." + window->GetUrl(
false));
45 }
else if (arg.find(
"SHOW:") == 0) {
46 std::string msg = arg.substr(5);
48 std::cout << msg << std::endl;
49 if (msg.find(
"Cnt:") == 0) {
50 int counter = std::stoi(msg.substr(4));
52 current_counter = counter;
55 auto p = msg.find(
"round-trip:");
57 round_trip = msg.substr(
p);
59 }
else if (arg ==
"halt") {
61 window_terminated =
true;
62 window->TerminateROOT();
80 modeHttpWindowThread = 3,
89void ping(
int nclients = 1,
int test_mode = 0)
91 num_clients = nclients;
93 batch_mode =
gROOT->IsBatch();
98 int major_mode = test_mode / 10;
99 test_mode = test_mode % 10;
100 if (test_mode > modeCivetThread)
101 test_mode = modeDefault;
105 else if (num_clients > 1000)
109 if (major_mode == majorLongpoll)
116 if ((test_mode == modeHttpThread) || (test_mode == modeHttpWindowThread))
120 if (test_mode == modeMinimalTimer)
132 window->SetConnLimit(num_clients);
137 std::string fname = __FILE__;
138 auto pos = fname.find(
"ping.cxx");
142 fname =
gROOT->GetTutorialsDir() + std::string(
"/visualisation/webgui/ping/");
143 fname.append(
"ping.html");
144 window->SetDefaultPage(
"file:" + fname);
147 window->SetGeometry(300, 500);
151 window->SetDataCallBack(ProcessData);
154 if (test_mode == modeCivetThread)
155 window->UseServerThreads();
157 if (test_mode == modeHttpWindowThread)
158 window->StartThread();
162 window->Show(batch_mode ?
"headless" :
"");
164 std::cout <<
"Window url is: " << window->GetUrl(
true) << std::endl;
168 const int run_limit = 200;
169 const double fullrun_time = 100., startup_time = 70.;
170 start_tm = firstmsg_tm = std::chrono::high_resolution_clock::now();
171 window->WaitFor([=](
double tm) {
172 return (current_counter >= run_limit) || (tm > fullrun_time) || ((current_counter == 0) && (tm > startup_time))
176 stop_tm = std::chrono::high_resolution_clock::now();
177 auto startuptime_int = std::chrono::duration_cast<std::chrono::milliseconds>(firstmsg_tm - start_tm);
178 auto runttime_int = std::chrono::duration_cast<std::chrono::milliseconds>(stop_tm - firstmsg_tm);
180 if (current_counter >= run_limit)
181 std::cout <<
"PING-PONG TEST COMPLETED " << round_trip;
183 std::cout <<
"PING-PONG TEST FAIL cnt:" << current_counter;
185 std::cout <<
" startup: " << startuptime_int.count() <<
"ms"
186 <<
" run: " << runttime_int.count() <<
"ms" << std::endl;
winID h TVirtualViewer3D TVirtualGLPainter p
static std::shared_ptr< RWebWindow > Create()
Create new RWebWindow Using default RWebWindowsManager.
static void SetSingleConnMode(bool on=true)
Enable or disable single connection mode (default on) If enabled, one connection only with any web wi...
static TString ToJSON(const T *obj, Int_t compact=0, const char *member_name=nullptr)
virtual void SetValue(const char *name, const char *value, EEnvLevel level=kEnvChange, const char *type=nullptr)
Set the value of a resource or create a new resource.