| 1 | /////////////////////////////////////////////////////////////////////////////// |
| 2 | // Copyright (c) 2000-2014 Ericsson Telecom AB |
| 3 | // All rights reserved. This program and the accompanying materials |
| 4 | // are made available under the terms of the Eclipse Public License v1.0 |
| 5 | // which accompanies this distribution, and is available at |
| 6 | // http://www.eclipse.org/legal/epl-v10.html |
| 7 | /////////////////////////////////////////////////////////////////////////////// |
| 8 | #ifndef STOPWATCH_HH_ |
| 9 | #define STOPWATCH_HH_ |
| 10 | |
| 11 | #include <sys/time.h> |
| 12 | |
| 13 | class Stopwatch { |
| 14 | public: |
| 15 | Stopwatch(const char *name); |
| 16 | ~Stopwatch(); |
| 17 | private: |
| 18 | struct timeval tv_start; |
| 19 | const char *my_name; // not owned |
| 20 | private: |
| 21 | Stopwatch(const Stopwatch&); // no copy |
| 22 | Stopwatch& operator=(const Stopwatch&); // no assignment |
| 23 | }; |
| 24 | |
| 25 | #ifdef NDEBUG |
| 26 | #define STOPWATCH(s) ((void)(s)) |
| 27 | #else |
| 28 | #define STOPWATCH(s) Stopwatch chrono_meter(s) |
| 29 | #endif |
| 30 | |
| 31 | #endif /* STOPWATCH_HH_ */ |