12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
-
-
-
-
-
-
- #ifndef TIMER_H_INC
- #define TIMER_H_INC
-
- #include <iostream>
- #include <fstream>
- #include <ctime>
- #ifdef LEMMAUSEOMP
- #include "omp.h"
- #endif
-
- #include "lemma.h"
-
- namespace Lemma {
-
-
- class jsw_timer {
-
- public:
-
-
-
- jsw_timer(): start ( std::clock() ), elapsed ( 0.0 ) {
-
- }
-
-
-
- void begin() {
- #ifdef LEMMAUSEOMP
- start = omp_get_wtime();
- #else
- start = std::clock();
- #endif
- elapsed = 0.0;
- }
-
-
-
- Real end() {
-
- #ifdef LEMMAUSEOMP
- elapsed = static_cast<Real> (omp_get_wtime()) - start;
- return elapsed;
- #else
- elapsed = static_cast<Real> ( std::clock() ) - start;
- return elapsed /= CLOCKS_PER_SEC;
- #endif
-
- }
-
-
-
- Real last() const { return elapsed; }
-
- private:
- std::clock_t start;
- Real elapsed;
- };
-
- }
-
- #endif
|