1 // Copyright 2019 The Dawn Authors 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 #ifndef UTILS_TIMER_H_ 16 #define UTILS_TIMER_H_ 17 18 namespace utils { 19 20 class Timer { 21 public: ~Timer()22 virtual ~Timer() { 23 } 24 25 // Timer functionality: Use start() and stop() to record the duration and use 26 // getElapsedTime() to query that duration. If getElapsedTime() is called in between, it 27 // will report the elapsed time since start(). 28 virtual void Start() = 0; 29 virtual void Stop() = 0; 30 virtual double GetElapsedTime() const = 0; 31 32 // Timestamp functionality: Use getAbsoluteTime() to get an absolute time with an unknown 33 // origin. This time moves forward regardless of start()/stop(). 34 virtual double GetAbsoluteTime() = 0; 35 }; 36 37 Timer* CreateTimer(); 38 39 } // namespace utils 40 41 #endif // UTILS_TIMER_H_ 42