helper function: compare two SYSTEMTIME, to get time span
来源:互联网 发布:js防水液体怎么用 编辑:程序博客网 时间:2024/05/17 23:44
// testTime.cpp : Defines the entry point for the console application.//#include "stdafx.h"#include <windows.h>/// tmNow can get from current time/// tmPrev can get form file already exist/// i want compare two time, get time span. e.g. tmX - tmY = 3 secondLONGLONG SecondTimeSpan(SYSTEMTIME &tmNow, SYSTEMTIME & tmPrev);int _tmain(int argc, _TCHAR* argv[]){ int iIndex = 0; DWORD dwTimeSleep = 0; LONGLONG llTimeSpan = 0; SYSTEMTIME tmPrev; SYSTEMTIME tmNow; for (iIndex = 0; iIndex < 10; iIndex++) { ::GetSystemTime(&tmPrev); dwTimeSleep = iIndex * 1000; ::Sleep(dwTimeSleep); ::GetSystemTime(&tmNow); llTimeSpan = SecondTimeSpan(tmNow, tmPrev); _tprintf(L"Sleep(%d Second), time span is %ld Second\r\n", iIndex, llTimeSpan); } /** run result Sleep(0 Second), time span is 0 Second Sleep(1 Second), time span is 1 Second Sleep(2 Second), time span is 2 Second Sleep(3 Second), time span is 3 Second Sleep(4 Second), time span is 4 Second Sleep(5 Second), time span is 5 Second Sleep(6 Second), time span is 6 Second Sleep(7 Second), time span is 7 Second Sleep(8 Second), time span is 8 Second Sleep(9 Second), time span is 9 Second */ getwchar();return 0;}LONGLONG SecondTimeSpan(SYSTEMTIME &tmNow, SYSTEMTIME & tmPrev){ union FileTimeUnion { FILETIME fileTime; ULARGE_INTEGER ul; } ; LONGLONG llSecond = 0; FileTimeUnion ftNow; FileTimeUnion ftPrev; SystemTimeToFileTime(&tmNow, &ftNow.fileTime); SystemTimeToFileTime(&tmPrev, &ftPrev.fileTime); llSecond = (ftNow.ul.QuadPart - ftPrev.ul.QuadPart); llSecond /= 10000; ///< ms counter llSecond /= 1000; ///< second counter return llSecond;}
0 0
- helper function: compare two SYSTEMTIME, to get time span
- php time to systemtime
- Two more accurate ways to get time elapsed than clock()
- to get time
- Time To Get Up
- Time To Get Up
- Time To Get Up
- Time To Get Up
- HDU6077-Time To Get Up
- Time To Get Up HDU
- HDU6077-Time To Get Up
- hdu6077 Time To Get Up
- How to compare two strings with Linq to Entity
- How to create a File-Compare function in Visual C#
- To compare two nanoTime values ,不解,先记下
- WMI---Function---Helper
- How to compare two cells value in Grid via Compare Validator?
- How to get the current epoch time
- 【C/C++】C++基础重盲点拾穗
- 小小的Enum(枚举),大大的作为
- Latex设定表格列宽
- 小程序:Java下载单页HTML(可下载引用资源)
- C语言 未完全
- helper function: compare two SYSTEMTIME, to get time span
- 跑分都浮云,电脑安装android-x86 4.3教程
- Mina学习笔记(二) 简单客户端实例
- 写代码烦躁时看看,挺好
- 2.2: 随机生成一个n bit位的长整数
- Java实现局域网内单播
- second order system analysis in adaptive control 自控 带零点的二阶系统matlab仿真分析
- #英文版 CS145 1#
- 不可逆加密思路