| 1 | /* -*- C++ -*- */cxx . . $ `<file>/vendor/Heap-Layers/utility/timer.h`/ |
| 2 | |
| 3 | /* |
| 4 | |
| 5 | Heap Layers: An Extensible Memory Allocation Infrastructure |
| 6 | |
| 7 | Copyright (C) 2000-2020 by Emery Berger |
| 8 | http://www.emeryberger.com |
| 9 | [email protected] |
| 10 | |
| 11 | Heap Layers is distributed under the terms of the Apache 2.0 license. |
| 12 | |
| 13 | You may obtain a copy of the License at |
| 14 | http://www.apache.org/licenses/LICENSE-2.0 |
| 15 | |
| 16 | */ |
| 17 | |
| 18 | #ifndef HL_TIMER_H |
| 19 | #define HL_TIMER_Hcxx . . $ `vendor/Heap-Layers/utility/timer.h:19:9`! |
| 20 | |
| 21 | /** |
| 22 | * @class Timer |
| 23 | * @brief A portable class for high-resolution timing. |
| 24 | * |
| 25 | * This class simplifies timing measurements across a number of platforms. |
| 26 | * |
| 27 | * @code |
| 28 | * Timer t; |
| 29 | * t.start(); |
| 30 | * // do some work |
| 31 | * t.stop(); |
| 32 | * cout << "That took " << (double) t << " seconds." << endl; |
| 33 | * @endcode |
| 34 | * |
| 35 | */ |
| 36 | |
| 37 | /* Updated to use new C++11 high-resolution timer classes. */ |
| 38 | |
| 39 | #if (__cpluspluscxx . . $ `<built-in>:449:9`! < 201103) |
| 40 | #include "timer-old.h" |
| 41 | #else |
| 42 | |
| 43 | #include <chrono> |
| 44 | |
| 45 | namespace HLcxx . . $ HL/ { |
| 46 | |
| 47 | class Timercxx . . $ HL/Timer# { |
| 48 | public: |
| 49 | |
| 50 | Timercxx . . $ HL/Timer#Timer(49f6e7a06ebc5aa8).() { |
| 51 | _startcxx . . $ HL/Timer#_start. =cxx . . $ std/chrono/time_point#`operator=`(93a95c332a91517c). _endcxx . . $ HL/Timer#_end.; |
| 52 | _elapsedcxx . . $ HL/Timer#_elapsed. = 0.0; |
| 53 | } |
| 54 | |
| 55 | void startcxx . . $ HL/Timer#start(49f6e7a06ebc5aa8).() { |
| 56 | _startcxx . . $ HL/Timer#_start. =cxx . . $ std/chrono/time_point#`operator=`(6b274d18a8a9dc89). stdcxx . . $ std/::chronocxx . . $ std/chrono/::high_resolution_clockcxx . . $ std/chrono/_V2/high_resolution_clock#::nowcxx . . $ std/chrono/_V2/system_clock#now(acb7c844e4d83bb).(); |
| 57 | _endcxx . . $ HL/Timer#_end. =cxx . . $ std/chrono/time_point#`operator=`(93a95c332a91517c). _startcxx . . $ HL/Timer#_start.; |
| 58 | } |
| 59 | |
| 60 | void stopcxx . . $ HL/Timer#stop(49f6e7a06ebc5aa8).() { |
| 61 | _endcxx . . $ HL/Timer#_end. =cxx . . $ std/chrono/time_point#`operator=`(6b274d18a8a9dc89). stdcxx . . $ std/::chronocxx . . $ std/chrono/::high_resolution_clockcxx . . $ std/chrono/_V2/high_resolution_clock#::nowcxx . . $ std/chrono/_V2/system_clock#now(acb7c844e4d83bb).(); |
| 62 | stdcxx . . $ std/::chronocxx . . $ std/chrono/::durationcxx . . $ std/chrono/duration#<double> elapsed_secondscxx . . $ std/chrono/duration#duration(883dabd2b674dc41). = _endcxx . . $ std/chrono/duration#duration(a833b3f73e1ac0ab). -cxx . . $ std/chrono/operator-(37d29b8d7121dc12). _startcxx . . $ HL/Timer#_start.; |
| 63 | _elapsedcxx . . $ HL/Timer#_elapsed. = elapsed_seconds.countcxx . . $ std/chrono/duration#count(8f5363d873dd4781).(); |
| 64 | } |
| 65 | |
| 66 | operatorcxx . . $ HL/Timer#`operator double`(31fa7155c10fdd13). double() { |
| 67 | return _elapsedcxx . . $ HL/Timer#_elapsed.; |
| 68 | } |
| 69 | |
| 70 | private: |
| 71 | stdcxx . . $ std/::chronocxx . . $ std/chrono/::time_pointcxx . . $ std/chrono/time_point#<stdcxx . . $ std/::chronocxx . . $ std/chrono/::high_resolution_clockcxx . . $ std/chrono/_V2/high_resolution_clock#> _startcxx . . $ HL/Timer#_start., _endcxx . . $ HL/Timer#_end.; |
| 72 | double _elapsedcxx . . $ HL/Timer#_elapsed.; |
| 73 | }; |
| 74 | |
| 75 | } |
| 76 | |
| 77 | #endif // version of C++ |
| 78 | |
| 79 | #endif |