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