/* Copyright 2015 The TensorFlow Authors. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ==============================================================================*/ // Portions Copyright (c) Microsoft Corporation #pragma once #include #include namespace onnxruntime { #ifdef _WIN32 using TIME_SPEC = int64_t; #else using TIME_SPEC = timespec; #endif // Get a time stamp counter // If the function succeeds, return true. If the function fails, return false bool GetMonotonicTimeCounter(TIME_SPEC* value); void SetTimeSpecToZero(TIME_SPEC* value); void AccumulateTimeSpec(TIME_SPEC* base, const TIME_SPEC* start, const TIME_SPEC* end); // Return the interval in seconds. // If the function fails, the return value is zero double TimeSpecToSeconds(const TIME_SPEC* value); /// \brief An interface used by the onnxruntime implementation to /// access timer related operations. class EnvTime { public: EnvTime(); virtual ~EnvTime() = default; /// \brief Returns a default impl suitable for the current operating /// system. /// /// The result of Default() belongs to this library and must never be deleted. static EnvTime* Default(); /// \brief Returns the number of micro-seconds since the Unix epoch. virtual uint64_t NowMicros() = 0; /// \brief Returns the number of seconds since the Unix epoch. virtual uint64_t NowSeconds() { return NowMicros() / 1000000L; } }; } // namespace onnxruntime