measuring the performance of some fragments of codes
Hi FOAMers,
I added some lines of code to a solver and would like to measure the performance of each part, e.g pressure solver, momentum solver and so on, Would it be the EXACT way of measuring? double a = clock::getTime(); THE CODE; double b = clock::getTime(); elapsed cpu time for that part of code EXACTLY is : (b-a) ? ( I expected to get nearly same value, but using the above method,sometimes provides strange results. e.g for a particular fragment of code, it gives performance of 9%, and sometimes 15% (the simulation is converged) actually when i print out the value of the scalar/double a or b, it seems that it can be 9 precision number ,so subtraction may lead to some errors due to that range of accuracy ) Thanks in advance. UPDATE : using 'elapsedCpuTime' gave accurate time and solved the problem. |
All times are GMT -4. The time now is 10:47. |