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 Goyal
    Manish Goyal
    Re: 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
  • vignesh1988i
    vignesh1988i
    YA 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 Goyal
    Manish Goyal
    Sorry vignesh..your question confuse me..
    Is there any difference between processor time and run time?
    sorry if my question is silly?
  • vignesh1988i
    vignesh1988i
    ok 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_cs
    ms_cs
    vignesh1988i
    ok 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..
  • vignesh1988i
    vignesh1988i
    i 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_cs
    ms_cs
    What is the problem you faced with that? post what you tried, here
  • vignesh1988i
    vignesh1988i
    In 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 Goyal
    Manish Goyal
    I 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_cs
    ms_cs
    see this link,

    #-Link-Snipped-#
  • vignesh1988i
    vignesh1988i
    actually 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 Goyal
    Manish Goyal
    Try 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
                                        
  • vignesh1988i
    vignesh1988i
    HMMMM ๐Ÿ˜€ ๐Ÿ˜€ 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...