dimanche 23 février 2020

Time a function within a loop [closed]

I am trying to get a time breakdown of different parts of a loop. For example :-

for (i = 0; i < 1000; i++) {
    //some code
    foo(); (Total time taken by foo for all 1000 iterations)
    //some code
}

I been using gettimeofday() until now but not sure how to use chrono library or any such timer for this use case. Any help would be appreciated.

Aucun commentaire:

Enregistrer un commentaire