#include
#include
int main()
{
 clock_t st,end;
 long i,j,t;
 st=clock();
 for(i=0;i<10000L;i++)
  for (j=0;j<50000L;j++)
  t=0; 
 end=clock();
 printf("\nSTARTING CLOCK: %lf",(double)st);
 printf("\nEnding Clock  : %lf",(double)end);
 printf("\n%lf",(double)((end-st)/CLK_TCK));
 return 0;
}
*/
#include
#include
main()
{
 clock_t st,en;
   int arr[10000],*ptr=arr,n,t;
     float fir[5],sec[5],res;
     unsigned long i,j;
      for(t=0;t<5;t++)
         {
           st=clock();
     for(j=0;j<10000L;j++)
       for(i=0;i<10000;i++)
         {
             arr[i]=1;
              }
     en =clock();
     printf("\nFIRST :  %lf\n",fir[t]=(en-st)/CLK_TCK);
     st=clock();
      for(j=0;j<10000L;j++)
        for(i=0;i<10000;i++)
          {
             *(ptr+i)=1;
              }
      en =clock();
      printf("SECOND: %lf",sec[t]=(en-st)/CLK_TCK);
      printf("\nDIFFERENCE  :  %lf\n",*(fir+t)-*(sec+t));
         }
     
      for(t=0;t<5;t++)
        res=res+*(fir+t)+*(sec+t);
       printf("\nTOTAL TIME IS : %lf\n",res);
       res=0;
      for(t=0;t<5;t++)
               res=res+(*(fir+t)-*(sec+t));
       printf("\nTOTAL TIME SAVE IS :%lf\n",res);
       printf("\n\nEND");
       return 0;
        }
ShoutBox
Blog Archive
- 
▼ 
2010
            (22)
          
- 
▼ 
January
            (22)
          
- Linklist Node delete program in C
 - Link List program in c
 - Assembler program in C
 - Accessing array in C using pipe
 - Fork IPC program in C
 - Executing another program in C
 - Time program in C
 - Sorting Program in C using fork and pipe
 - Use of vfork in Unix C program
 - Fork and Wait in Unix IPC C program
 - Pipes in Unix IPC
 - Complete sum program in Unix IPC
 - Sort program in C using Unix IPC fork and pipe
 - Shared memory in Unix C program
 - Sum of N numbers program in C using Fork and Pipe IPC
 - Inter process communication with fork and pipe
 - Fork and Pipe program in C
 - Fork with Pipe Program in C
 - Another Fork program in C
 - Simple Fork Program in Linux/Unix C
 - Recursive File System Search Program in C
 - Assembler Program in C
 
 
 - 
▼ 
January
            (22)
          
 
Join With Me...
3:18 AM
Subscribe to:
Post Comments (Atom)


0 comments:
Post a Comment