Hi,
I am doing a plotting test with a TGraph2D object used in a standalone application running on a MacBook Air (11-inch, Early 2014) 1.4 GHz Intel Core i5, 8 GB 1600 MHz DDR3, l HD Graphics 5000 1536 MB.
I use ROOT v6.04.08 and Xcode 7.2.
The relevant code is:
void GUI::Plot()
{
watch->Start();
phi_x += PHI;
phi_y += PHI;
if (phi_x > (2*PI - PHI))
{
phi_x = 0;
}
if (phi_y > (2*PI - PHI))
{
phi_y = 0;
}
graph->Clear();
for (i = 0; i < N; i++)
{
for (j = 0; j < M; j++)
{
k = j + i*N;
x = i;
y = j;
z = A*sin(6.28*i/M + phi_x)*cos(6.28*j/N + phi_y);
graph->SetPoint(k, x, y, z);
}
}
printf("Elasped time (computation) [s] = %lf\n", watch->CpuTime());
watch->Start();
graph->Draw("surf1");
fCanvas->Modified();
fCanvas->Update();
printf("Elasped time (visualization) [s] = %lf\n", watch->CpuTime());
}
The method is invoked by a timer somewhere else defined in my code.
This code is supposed to generate an animated moving sheet with sinusoidal bumps propagating on it.
The calculation of the data points (M x N = 20 x 20 = 400) is made on the fly (not recalculated) on purpose in order to have a benchmark of the computational capabilities.
As expected, the time required for the computation, printed by a stopwatch, is basically zero.
But the time required for the visualisation varies around 150ms for each render.
The timer set to trigger the plotting method as been set to 100ms, so the plot comes always late. Originally, I thought it was possible to get plots every 20ms (so that I could think of making a fluid animation) but this has been impossible to achieve.
I can understand the plotting requires some time in order to be generated, but what I cannot understand is why, at the same time, in case I spin my plot by dragging the graph with the cursor in order to change the viewpoint this movement occurs very rapidly. I can, for instance, spin my plot in crazy fast way and have it rendered in different new viewpoints basically immediately but still each frame is generated very slowly.
The latter observation make me thinking I am doing something wrong while generating such plot.
What am i doing wrong and why is my plot so slow?
P.S. please find a screenshot of my animated plot attached to this post.
Best regards,
Erik