| 1 | /* |
| 2 | * IXBench.h |
| 3 | * Author: Benjamin Sergeant |
| 4 | * Copyright (c) 2017-2020 Machine Zone, Inc. All rights reserved. |
| 5 | */ |
| 6 | #pragma once |
| 7 | |
| 8 | #include <chrono> |
| 9 | #include <stdint.h> |
| 10 | #include <string> |
| 11 | |
| 12 | namespace ix |
| 13 | { |
| 14 | class Bench |
| 15 | { |
| 16 | public: |
| 17 | Bench(const std::string& description); |
| 18 | ~Bench(); |
| 19 | |
| 20 | void reset(); |
| 21 | void record(); |
| 22 | void report(); |
| 23 | void setReported(); |
| 24 | uint64_t getDuration() const; |
| 25 | |
| 26 | private: |
| 27 | std::string _description; |
| 28 | std::chrono::time_point<std::chrono::high_resolution_clock> _start; |
| 29 | uint64_t _duration; |
| 30 | bool _reported; |
| 31 | }; |
| 32 | } // namespace ix |
| 33 | |