| 1 | #ifndef _melder_time_h_ |
| 2 | #define _melder_time_h_ |
| 3 | /* melder_time.h |
| 4 | * |
| 5 | * Copyright (C) 1992-2016,2018,2020,2021,2025 Paul Boersma |
| 6 | * |
| 7 | * This code is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License as published by |
| 9 | * the Free Software Foundation; either version 3 of the License, or (at |
| 10 | * your option) any later version. |
| 11 | * |
| 12 | * This code is distributed in the hope that it will be useful, but |
| 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| 15 | * See the GNU General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License |
| 18 | * along with this work. If not, see <http://www.gnu.org/licenses/>. |
| 19 | */ |
| 20 | |
| 21 | double Melder_stopwatch (); |
| 22 | |
| 23 | void Melder_sleep (double duration); |
| 24 | |
| 25 | double Melder_clock (); // typically the number of seconds since system start-up, with microsecond precision |
| 26 | |
| 27 | class MelderStopwatch { |
| 28 | double _lastTime { 0.0 }; |
| 29 | public: |
| 30 | MelderStopwatch () { |
| 31 | our _lastTime = Melder_clock (); |
| 32 | } |
| 33 | double operator() () { |
| 34 | const double now = Melder_clock (); |
| 35 | const double timeElapsed = now - our _lastTime; |
| 36 | our _lastTime = now; |
| 37 | return timeElapsed; |
| 38 | } |
| 39 | }; |
| 40 | |
| 41 | autostring32 date_STR (); |
| 42 | autostring32 date_utc_STR (); |
| 43 | |
| 44 | autostring32 date_iso_STR (); |
| 45 | autostring32 date_utc_iso_STR (); |
| 46 | |
| 47 | autoVEC date_VEC (); |
| 48 | autoVEC date_utc_VEC (); |
| 49 | |
| 50 | /* End of file melder_time.h */ |
| 51 | #endif |