I am writing code in C ++ and I would like to test the performance of its functions. I've measured this before, but with the implementation of the chrono library and the for loop in bash, but the measurements were unreliable as the program starts at all times. I ran the code 2k times three times and now I know it's a bad idea. I would like to do this with $ time but I have to ask about two things. The first is any way to mesure all functions separately with one $ time command and get the output (real, user, sys) to the file. And the secend question, if I've couple programs it is possible to one commend start each after other?

  • Does this answer your question? How to get execution time of a script effectively? meaning that you need measure the time before and after each function you used; next part this does your question What are the shell's control and redirection operators? meaning that you need && operator between first and second commands – αғsнιη Dec 21 '20 at 20:54
  • That almost answer it. I'll precise first part of question. In the .cpp file I've two functions - f1() and f2(). Could I measure by bash time together but with two outputs (real,user,sys)? – user447509 Dec 21 '20 at 21:09
  • no, you cannot, you can do with C++ itself, see stackoverflow.com/q/22387586/4023950; by the way your question seems to be off-topic here since still I cannot get how C++ relates to Bash in your question. – αғsнιη Dec 21 '20 at 21:11
  • Thank you very much and I'm sorry but nobody wanted help me with that – user447509 Dec 21 '20 at 21:13
  • 2
    people will help; please also read this stackoverflow.com/help/how-to-ask if you want they help better, thanks; if you clarify your question after reading the link above, you may ask your question on Stackoverflow.com instead (I think that's more on topic there as here), then you will get help there as well; but remember do not cross-post your question over there and other stackexchange sites. – αғsнιη Dec 21 '20 at 21:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.