[vtkusers] Newbie question about VTK speed
T.R.Shashwath
trshash at gmail.com
Sun Jan 6 01:20:36 EST 2008
Hi Mike,
If you want to test the speed of VTK (or anything else), you should test
*only* that in your main (in this case, the rendering) loop. Having two sins
and three floating point (or worse in all probability, double)
multiplications in the same loop as viewer->Render() is definitely going to
slow it down, as all these are extremely costly functions.
If you really want to test speed, try rendering the same image N times,
instead of calculating N images. You can do that with a very simple
modification to your code; change your rendering loop so that it's only
rendering, and do the image calculation once outside.
for(x=0.0,i=0;i<xSize+1;i++,x+=dx)
for(y=0.0,j=0;j<ySize+1;j++,y+=dy)
*ptr++ = sin(8.0*Pi*x)*sin(8.0*Pi*y) * 0.5;
for(k=0;k<NumberOfFrames;k++)
{
image->Modified();
viewer->Render();
}
This gives me 7.05 seconds for a 1024x1024 image on my pipsqueak of an Nvidia
6200 on a single core Athlon 64, so your speeds may be better.
If you want to try your original idea, the above code can still be modified to
achieve it. In the render loop, keep rescaling the image in-place and marking
the image as modified before rendering. Even this shouldn't make it slower
than by say, one second.
There are more advanced and interesting techniques for these kinds fo things,
but you can leave that for a rainy day.
Regards,
Shash
-------------------------------------------------------
--
He had forty-two boxes, all carefully packed,
With his name painted clearly on each:
But, since he omitted to mention the fact,
They were all left behind on the beach.
More information about the vtkusers
mailing list