相当于 Windows 的 gettimeday()

编程入门 行业动态 更新时间:2024-10-26 06:26:21
本文介绍了相当于 Windows 的 gettimeday()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

有谁知道 Windows 环境中 gettimeofday() 函数的等效函数?我正在比较 Linux 和 Windows 中的代码执行时间.我正在使用 MS Visual Studio 2010,它一直说,标识符gettimeofday"未定义.

Does anyone know an equivalent function of the gettimeofday() function in Windows environment? I am comparing a code execution time in Linux vs Windows. I am using MS Visual Studio 2010 and it keeps saying, identifier "gettimeofday" is undefined.

推荐答案

GetLocalTime() 用于系统时区的时间,GetSystemTime() 用于 UTC.那些以 SYSTEMTIME 结构返回日期/时间,在那里它被解析为年、月等.如果你想要一个自纪元以来的秒数,请使用 SystemTimeToFileTime()GetSystemTimeAsFileTime().FILETIME 是一个 64 位值,自 UTC 时间 1601 年 1 月 1 日起间隔为 100ns.

GetLocalTime() for the time in the system timezone, GetSystemTime() for UTC. Those return the date/time in a SYSTEMTIME structure, where it's parsed into year, month, etc. If you want a seconds-since-epoch time, use SystemTimeToFileTime() or GetSystemTimeAsFileTime(). The FILETIME is a 64-bit value with the number of 100ns intervals since Jan 1, 1601 UTC.

对于间隔时间,使用GetTickCount().它返回自启动以来的毫秒数.

For interval taking, use GetTickCount(). It returns milliseconds since startup.

要以最佳分辨率(仅受硬件限制)获取间隔,请使用 QueryPerformanceCounter().

For taking intervals with the best possible resolution (limited by hardware only), use QueryPerformanceCounter().

这篇关于相当于 Windows 的 gettimeday()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

更多推荐

[db:关键词]

本文发布于:2023-04-27 11:48:29,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1154174.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Windows   gettimeday

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!