1 // Copyright (C) 2019 Google LLC 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 ICING_LEGACY_CORE_ICING_TIMER_H_ 16 #define ICING_LEGACY_CORE_ICING_TIMER_H_ 17 18 #include <sys/time.h> 19 20 #include <ctime> 21 22 namespace icing { 23 namespace lib { 24 25 // A simple stop-watch timer for performance measurement. 26 class IcingTimer { 27 public: 28 static double WallTimeNow(); 29 30 IcingTimer(); 31 32 void Reset(); 33 34 // Elapsed wall time since last Reset(). 35 double Elapsed() const; 36 37 private: 38 static double ClockTime(); 39 40 double start_; 41 }; 42 43 } // namespace lib 44 } // namespace icing 45 #endif // ICING_LEGACY_CORE_ICING_TIMER_H_ 46