Measuring execution time of a call to system() in C++

后端 未结 3 1916
甜味超标
甜味超标 2021-01-14 02:46

I have found some code on measuring execution time here http://www.dreamincode.net/forums/index.php?showtopic=24685

However, it does not seem to work for calls to sy

3条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-14 03:42

    Tuomas Pelkonen already presented the gettimeofday method that allows to get times with a resolution to the microsecond.

    In his example he goes on to convert to double. I personally have wrapped the timeval struct into a class of my own that keep the counts into seconds and microseconds as integers and handle the add and minus operations correctly.

    I prefer to keep integers (with exact maths) rather than get to floating points numbers and all their woes when I can.

提交回复
热议问题