COSMOS core  1.0.2 (beta)
Comprehensive Open-architecture Solution for Mission Operations Systems
elapsed_time_test.cpp File Reference
#include <stdio.h>
#include <sys/time.h>
#include "timelib.h"
Include dependency graph for elapsed_time_test.cpp:

Functions

int main ()
 

Function Documentation

int main ( )
37 {
38 struct timeval first, last, delta;
39 struct timezone x;
40 
41 int num=rand();
42 int flag=0;
43 
44 float timeDiff;
45 
46 printf("Calculating...\n");
47 
48 //Get the initial time
49 gettimeofday(&first, &x);
50 
51 //Do the process
52 for(int i;i<1000000;i++)
53 {
54  if(num==i)
55  {
56  printf("Found: %d ", num);
57  flag=1;
58  }
59 }
60 
61 if(flag==0)
62 {
63  printf("No results found ");
64 }
65 
66 //Get the final time
67 gettimeofday(&last, &x);
68 
69 //Caculate the difference
70 timeDiff=elapsed_time(delta,first,last);
71 printf("in %f milliseconds\n", timeDiff);
72 }
static double delta
Definition: agent_exec-2-0.cpp:141
int i
Definition: rw_test.cpp:37
x
Definition: inputfile.py:6
float elapsed_time(struct timeval dif, struct timeval a, struct timeval b)
Definition: old/sensors/imu_microstrain/clock_test.cpp:65