How to find compilation/execution time in C?
how to find the compilation time or execution time in C??????? wat function we must use to find the operation time in milli seconds??????????? it's very urgent !!!!!!!!๐๐๐๐๐๐
Replies
-
Manish GoyalRe: A urgent help needed!!!!!! plzzzzz
Hello vignnesh there is no need of any function to know the run time
just do what i say?
In c++ program window
just write any program and execute it
after getting output click on option 'compile' in menu bar...then click 'information'
a window will open in which run time of program will be mentioned
''Don't confuse with c++ program window by which i mean blue screen''there you can execute both c++ and c program -
vignesh1988iYA THANKS allot for ur fast reply ๐ ๐ , but actually wat i need is the processor time .... but here its taking the whole run time (ie) as soon as the exe window opens to till it returns to the program screen or to editor.......
BUT I NEED THE PROCESSOR TIME , so can u help for that ๐ -
Manish GoyalSorry vignesh..your question confuse me..
Is there any difference between processor time and run time?
sorry if my question is silly? -
vignesh1988iok ok ok ๐ here i ll explain u with a neat example .......
let us take the code :
main()
{
int n;
clrscr();
printf("enter the number :");
scanf("%d",&n); Input session
if(n>0) line 6
printf("%d is +ve",n);
else if(n<0)
printf("%d is -ve",n);
else
printf(" 0 value "); line 11
getch();
}
here i need to calculate the execution time from line 6 to line 11 alone in milliseconds ๐ , because that one is the processing time where i do manipuations or operations na , ๐
But in the option "COMPILE" , the "INFORMATION" option is giving the total time in milliseconds , which is including the input time to till coming back to the editor mode ๐ ๐ that's why iam asking ๐ sorry ๐
thank u -
ms_csvignesh1988iok ok ok ๐ here i ll explain u with a neat example .......
let us take the code :
main()
{
int n;
clrscr();
printf("enter the number :");
scanf("%d",&n); Input session
if(n>0) line 6
printf("%d is +ve",n);
else if(n<0)
printf("%d is -ve",n);
else
printf(" 0 value "); line 11
getch();
}
here i need to calculate the execution time from line 6 to line 11 alone in milliseconds ๐ , because that one is the processing time where i do manipuations or operations na , ๐
But in the option "COMPILE" , the "INFORMATION" option is giving the total time in milliseconds , which is including the input time to till coming back to the editor mode ๐ ๐ that's why iam asking ๐ sorry ๐
thank u
Hey Dude ,
Sure you can calculate,
You can do this with the help of time.h header file,
if still you have problem let me know.. -
vignesh1988ii have tried that ๐ , but pl. let me know about ur view , which function we must use to get the process time in milliseconds ๐ , pl. reply me immediately ๐
thank u -
ms_csWhat is the problem you faced with that? post what you tried, here
-
vignesh1988iIn time.h , there is a structure called time_t as u know it......
i calculated the start time by giving :
main()
{
int n;
time_t t1 , t2;
clrscr();
scanf("%d",&n);
time(&t1);
//starting of the process
if(n%2==0)
printf("even")
else
printf("odd");
// end of the process
time(&t2);
printf("\n%d",difftime(t2,t1));
getch();
}
this only i gave , but am getting the answer in SEC. but i need the correct milliseconds time for the above code........ (ie) only the process time..... ๐ ๐ can u understand??????? -
Manish GoyalI don't know about this..but why don't you create a function that will convert seconds into milliseconds...may be you will get what you want?
-
ms_cssee this link,
#-Link-Snipped-# -
vignesh1988iactually i know the conversion,,, the problem is that i cant able to see the small difference when i get the o/p in seconds.........
for example :
for checking a given number is even or odd : we will check with the if - else construct.....
if( i%2==0) // this is the process for me.... i need to find out this time in milliseconds
if i check for a number whether it is +ve or -ve ,
if( a>0) // process
else if(a<0) // process
this time in milli seconds i need to find ๐ ๐
hope u can understand my question now fully ๐ ๐
can u give a solution for me ๐ ๐ -
Manish GoyalTry this it may help you
#include
#include #include void main() { int n; time_t t1 , t2; clrscr(); cin>>n; time(&t1); //starting of the process if(n%2==0) cout<<"even"; else cout<<"odd"; // end of the process double d; d=difftime(t2,t1); cout< I have made small changes -
vignesh1988iHMMMM ๐ ๐ i have tried that , i too converted into milliseconds too... but i can't able to see small changes or difference in time , since i need a precised value in the difference in timings only i asked u for a solution ๐ ๐ , sorry for troubling ๐
You are reading an archived discussion.
Related Posts
i need some ideas to mini project...in electrical and electronics engineering
plzzzzz help
Hello everybody
I need a help in solving this sample exam
the exam is here on this site
Final* Examination
because my exam is on monday and it will be...
Hi guys i want to make a circuit which generates the waveform given below...
Just using opamp, resistors , capacitors , diodes , thyristors , transistors , +5v dc supply,...
Highway passing through a building !!!
Gate Tower Building is a 16-story office building in Fukushima-ku, Osaka , Japan . And what makes it notable is the highway that passes...
Hi guys
I read somewhere that "the actual torque transmitted from the engine to the clutch is the total engine torque subtacted by the amount of torque required to accelerate...