+ 2

How to calculate total code compilation time in C?

I was trying to find out how much time it needed for a code written in C to compile and run. I have tried a function called clock () from time.h library. But I always get 0.0000000 second output. I think it should something like ms. Please see my code. Help me to get the output of code run time. https://code.sololearn.com/cmg0K6Ah54km/?ref=app

21st Apr 2018, 1:17 AM
Mohammad Nazmul Hossain
Mohammad Nazmul Hossain - avatar
3 Réponses
+ 4
I'm guessing they stubbed the library code with return 0.0
21st Apr 2018, 2:49 PM
John Wells
John Wells - avatar
+ 3
This works for me: double time_spent = ((double)end-begin)/CLOCKS_PER_SEC; printf ("\n\nTotal run time: %.20f",time_spent ); But not in the Code Playground on SoloLearn. I compiled it on the command-line. Code Playground always returns 0. There could well be a bug there, it might be worth reporting it to the SL team.
21st Apr 2018, 3:08 AM
Emma
+ 1
John Wells Can you please look at this issue?
21st Apr 2018, 8:09 AM
Mohammad Nazmul Hossain
Mohammad Nazmul Hossain - avatar