X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?p=ginac.git;a=blobdiff_plain;f=check%2Ftimer.cpp;h=140df2fee34d9a73c0488ad369111350da42b88e;hp=b6c3a6b81487dcb34789e6552cf94315cba0d922;hb=581244b7b8fc9b5f81291e1a3f5731939e3f3d8e;hpb=0160f9ab1da453641e30539abcf0eaa4162582eb;ds=sidebyside diff --git a/check/timer.cpp b/check/timer.cpp index b6c3a6b8..140df2fe 100644 --- a/check/timer.cpp +++ b/check/timer.cpp @@ -3,7 +3,7 @@ * A simple stop watch class. */ /* - * GiNaC Copyright (C) 1999-2005 Johannes Gutenberg University Mainz, Germany + * GiNaC Copyright (C) 1999-2008 Johannes Gutenberg University Mainz, Germany * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -86,18 +86,15 @@ double timer::read() #ifdef HAVE_RUSAGE if (running()) getrusage(RUSAGE_SELF, &used2); - elapsed = ((used2.ru_utime.tv_sec - used1.ru_utime.tv_sec) + - (used2.ru_stime.tv_sec - used1.ru_stime.tv_sec) + - (used2.ru_utime.tv_usec - used1.ru_utime.tv_usec) * 1e-6 + - (used2.ru_stime.tv_usec - used1.ru_stime.tv_usec) * 1e-6); + return ((used2.ru_utime.tv_sec - used1.ru_utime.tv_sec) + + (used2.ru_stime.tv_sec - used1.ru_stime.tv_sec) + + (used2.ru_utime.tv_usec - used1.ru_utime.tv_usec) * 1e-6 + + (used2.ru_stime.tv_usec - used1.ru_stime.tv_usec) * 1e-6); #else if (running()) used2 = clock(); - elapsed = double(used2 - used1)/CLOCKS_PER_SEC; + return double(used2 - used1)/CLOCKS_PER_SEC; #endif - // Results more accurate than 10ms are pointless: - return elapsed; - return 0.01*int(elapsed*100+0.5); } bool timer::running()