[vtkusers] Newbie question about VTK speed
Hans 'von Knackenpfeffer'
hansvp at hotmail.com
Sat Jan 5 20:15:09 EST 2008
It seems that you're calculating the sine function a lot of times. Pre-computing this to a table and then using this table in the loop might speed up your program significantly.
> Date: Fri, 4 Jan 2008 23:04:19 -0500
> From: francois.bertel at kitware.com
> To: vtkusers at vtk.org
> Subject: Re: [vtkusers] Newbie question about VTK speed
>
> I don't know but I see that you're doing computation in your loop. Try
> to time this overhead first by commenting out viewer->Render().
>
> On 1/4/08, Hughes, Mike <msh at cmrl.wustl.edu> wrote:
> > Thanks for the really fast answer.
> >
> > I checked my NVIDIA openGL settings and it seems that the vertical blank
> > option was not set (correct me if I'm wrong, I've attached a screen shot of
> > the dialog box I'm refering to).
> >
> > I'd be glad to check any other suggestions you might have.
> >
> > Regards,
> >
> > Mike
> >
> > PS
> > Do you have any idea of what sort of frame rates should I expect?
> >
> > -----Original Message-----
> > From: Francois Bertel [mailto:francois.bertel at kitware.com]
> > Sent: Friday, January 04, 2008 9:18 PM
> > To: Hughes, Mike
> > Subject: Re: [vtkusers] Newbie question about VTK speed
> >
> > Hi Mike,
> >
> > 180/2.57=70. It seems you have vertical blank sync option on with a monitor
> > working at 70Hz. If you want to benchmark the framerate, you have to set it
> > off. Run nvidia-settings, Uncheck "Sync to VBlank" in OpenGL Settings. or
> > in your shell , set the following environment variable to 0 (see any nvidia
> > documentation):
> > $export __GL_SYNC_TO_VBLANK=0
> >
> >
> > On 1/4/08, Hughes, Mike <msh at cmrl.wustl.edu> wrote:
> > > I've just started using VTK to do image processing. I wrote the
> > > program below (Vol-r5) to test the frame rate for writing different
> > > images to the screen of my computer (Dual dual-core Xeons with and
> > > VCQFX1500-PCIE-PB Nvidia 1500 video adapter running Ubuntu linux with
> > > working OpenGL drivers installed).
> > >
> > > When I run the program I get the following output:
> > > $ ./Vol-r5
> > > dt= 2.57 for: 180 frames
> > > Where dt is the execution time to compute and display 180 frames.
> > >
> > > This seems to be astoundingly slow for a machine with working OpenGL
> > > drivers installed. I've explored the VTK class hierarchy and it seems
> > > that if OpenGL is available it should be automatically used. I hope
> > > that I'm mistaken on this.
> > >
> > > Is there a way to display frames at a higher rate? I would ultmately
> > > like to display 512x512 images (which takes about 9 sec with the program
> > below).
> > >
> > > Vol-r5.cpp listing....
> > >
> > > #include "vtkImageWriter.h"
> > > #include "vtkImageReader.h"
> > > #include "vtkPointData.h"
> > > #include "vtkRenderer.h"
> > >
> > > //#include "vtkRenderWindow.h"
> > > //#include <vtkXOpenGLRenderWindow.h>
> > >
> > > #include "vtkImageViewer.h"
> > > #include "vtkRenderWindowInteractor.h"
> > > #include "vtkStructuredPoints.h"
> > > #include "vtkFloatArray.h"
> > > #include "vtkContourFilter.h"
> > > #include "vtkPolyDataMapper.h"
> > > #include "vtkActor.h"
> > > #include "vtkImageCast.h"
> > >
> > > #include <time.h>
> > >
> > > const float Pi=3.14159;
> > > const int NumberOfFrames=180;
> > >
> > > int main ()
> > > {
> > >
> > > float sp, z, y, x, s, dx,dy,scale;
> > > int i, j, k, ii, kOffset, jOffset, offset,h;
> > > int xSize=255;
> > > int ySize=255;
> > > int zSize=0;
> > > clock_t start, stop;
> > > dx=1.0/((double)xSize);
> > > dy=1.0/((double)ySize);
> > >
> > > vtkImageData *image = vtkImageData::New();
> > > image->SetDimensions(xSize+1,ySize+1,zSize+1);
> > > image->SetScalarTypeToFloat();
> > > image->AllocateScalars();
> > >
> > > float *ptr = static_cast<float*>(image->GetScalarPointer());
> > > float *startptr;
> > > startptr = ptr;
> > >
> > > vtkImageViewer *viewer = vtkImageViewer::New();
> > > viewer->SetInput(image);
> > > viewer->SetColorWindow(20.0);
> > > viewer->SetColorLevel(0.0);
> > > start=clock();
> > > for(scale=1.0,k=0;k<NumberOfFrames;k++,scale+=0.1)
> > > {
> > > ptr=startptr;
> > > 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++ = scale*sin(8.0*Pi*x)*sin(8.0*Pi*y);
> > > viewer->Render();
> > > }
> > > stop=clock();
> > > cout << " dt= " <<
> > > ((double)(stop-start))/((double)CLOCKS_PER_SEC) << " for: " <<
> > > NumberOfFrames << " frames" << endl;
> > >
> > > viewer->Delete();
> > > image->Delete();
> > > // Clean up
> > > return 1;
> > > }
> > >
> > > _______________________________________________
> > > This is the private VTK discussion list.
> > > Please keep messages on-topic. Check the FAQ at:
> > > http://www.vtk.org/Wiki/VTK_FAQ Follow this link to subscribe/unsubscribe:
> > > http://www.vtk.org/mailman/listinfo/vtkusers
> > >
> >
> >
> > --
> > François Bertel, PhD | Kitware Inc. Suite 204
> > 1 (518) 371 3971 x113 | 28 Corporate Drive
> > | Clifton Park NY 12065, USA
> >
> >
>
>
> --
> François Bertel, PhD | Kitware Inc. Suite 204
> 1 (518) 371 3971 x113 | 28 Corporate Drive
> | Clifton Park NY 12065, USA
> _______________________________________________
> This is the private VTK discussion list.
> Please keep messages on-topic. Check the FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
_________________________________________________________________
Get the power of Windows + Web with the new Windows Live.
http://www.windowslive.com?ocid=TXT_TAGHM_Wave2_powerofwindows_012008
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20080106/30e03364/attachment.htm>
More information about the vtkusers
mailing list