| // This file is part of Eigen, a lightweight C++ template library |
| // Copyright (C) 2024 The Eigen Authors |
| // This Source Code Form is subject to the terms of the Mozilla |
| // Public License v. 2.0. If a copy of the MPL was not distributed |
| // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. |
| #define WIN32_LEAN_AND_MEAN |
| // Elapsed CPU Time in seconds. |
| // For MSVC, use `GetProcessTimes` for proper CPU time - MSVC uses |
| // a non-standard `std::clock` implementation (see |
| // https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/clock?view=msvc-170). |
| // GetProcessTimes() uses 100-nanosecond time units. |
| FILETIME creation_time, exit_time, kernel_time, user_time; |
| GetProcessTimes(GetCurrentProcess(), &creation_time, &exit_time, &kernel_time, &user_time); |
| user.HighPart = user_time.dwHighDateTime; |
| user.LowPart = user_time.dwLowDateTime; |
| uint64_t time_100ns = user.QuadPart; |
| return static_cast<float>(time_100ns) / 10000000.0f; |
| return static_cast<float>(std::clock()) / static_cast<float>(CLOCKS_PER_SEC); |