From: rgourdeau AT mail DOT polymtl DOT ca (Richard Gourdeau) Subject: quick fix for bug in clock() (GNU-Win32 b18) 29 Nov 1997 03:08:21 -0800 Message-ID: <347F7298.6E12.cygnus.gnu-win32@mail.polymtl.ca> Reply-To: rgourdeau AT mail DOT polymtl DOT ca Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit To: gnu-win32 AT cygnus DOT com I have been using GNU-Win32 to do numerical computations. When attempting to benchmark some programs, I have realized than the function clock() does not work as expected. The following C++ program presents a quick fix to this problem. It has the advantage of not requiring to rebuild any of the files in the distribution. /* clock() example begin */ #include #include #include #if defined(_WIN32) /* Windows 95/NT */ #ifdef __GNUG__ /* Cygnus Gnu C++ for win32*/ #define clock() GetTickCount() /* quick fix for bug in clock() */ #endif #endif int main(void) { clock_t start, end; start = clock(); cout << "Clock start: " << start << "\n"; Sleep(2000); /* waits 2 sec */ end = clock(); cout << "Clock end: " << end << "\n"; cout << "The time was: "<< ((end - start) / (double)CLK_TCK) << "\n"; return 0; } /* clock() example end */ =================================================== Richard Gourdeau, Professeur Agrégé Departement de mathematiques et de genie industriel Ecole Polytechnique de Montreal C.P. 6079, Succ. Centre-ville Montreal (Quebec), Canada email: rgourdeau AT mail DOT polymtl DOT ca Tel: (514) 340-4711 poste 5863 Fax: (514) 340-4173 - For help on using this list (especially unsubscribing), send a message to "gnu-win32-request AT cygnus DOT com" with one line of text: "help".