I am Vignesh back to go4expert forums.... my login has been removed due to spam messages i have registered back with different login id i have a doubt regarding GCC.... how can i get the complete execution time in milliseconds and microseconds for a program executed through GCC.... is there any function in gcc???? let me know soon thanks in adavnce S.R.Vignesh
Code: #include <stdio.h> #include <time.h> int main(){ clock_t start = clock(); printf("\ncalculating time elapsed,please wait!\n"); /* Code you want timed here */ for (int i=0;i<30000;i++) for (int j=0;j<30000;j++){} /*end timed code*/ double timeElapsedInseconds=((double)clock() - start) / CLOCKS_PER_SEC; long timeElapsedInmilliseconds=(long)(1000*((double)clock() - start) / CLOCKS_PER_SEC); printf("Time elapsed: %f seconds\n",timeElapsedInseconds ); printf("Time elapsed: %ld milliseconds\n",timeElapsedInmilliseconds ); getchar(); return 0; } the code is for seconds and milliseconds