if statement - How to profile if in C++ -


is there tool know how many time if it's true , how many time false

for exemple:

if (vector.size() == 1)     return; do_something(); 

how know how many time if true?

if code inside function, can use static variable :

void function(){      static int cpttrue;     static int cptfalse;      if (vector.size() == 1){         cpttrue++;         return;     }     cptfalse++;     do_something(); } 

Comments