Main Page   Modules   Class Hierarchy   Compound List   File List   Compound Members   Related Pages   Examples  

test_timer.cpp

00001 /* Copyright (c) 2001 C. Grigorescu */
00002 
00003 #include <stdio.h>
00004 #include <stdlib.h>
00005 #include <string.h>
00006 #include <tip.h>
00007 
00008 int main(int argc, char *argv[])
00009 {
00010   // Test for the correct number of arguments in the command line.
00011   if (argc != 2) {
00012     cout << "Usage: " << argv[0] << " <input_image>" << endl;
00013     exit(0);
00014   }
00015 
00016   FloatImage im0;
00017   im0.readImage(argv[1]);
00018 
00019   // Create a Timer object.
00020   Timer t;
00021   FourierTransform a(im0);
00022 
00023   // Start the timer.
00024   t.Start();
00025 
00026   // Get the current time.
00027   float f1 = t.getTime();
00028   float f2;
00029   for (int i=0;i<10;i++) {
00030     a.fft();  
00031     a.ifft();
00032     f2 = t.getTime();
00033     // Display the time elapsed between the last two calls to getTime method.
00034     cout << "Time: " << f2 - f1 << endl;
00035   }
00036   // Stop the timer.
00037   t.Stop();
00038 
00039   // Display the time elapsed between the starting and the stopping of the timer.
00040   t.Print();
00041 }