Windows 毫秒计时
#include <windows.h>
#include <iostream>
using namespace std;
LARGE_INTEGER MilliSecondTimeStamp()
{
LARGE_INTEGER m_liPerfStart = { 0 };
QueryPerformanceCounter(&m_liPerfStart);
return m_liPerfStart;
}
long long MilliSecondTimeCost(LARGE_INTEGER begin, LARGE_INTEGER end)
{
LARGE_INTEGER m_liPerfFreq = { 0 };
//获取每秒多少CPU Performance Tick
QueryPerformanceFrequency(&m_liPerfFreq);
return ((end.QuadPart - begin.QuadPart) * 1000) / m_liPerfFreq.QuadPart;
}
int main(void)
{
LARGE_INTEGER begin = MilliSecondTimeStamp();
for (int i = 0; i < 10000; i++)
cout << i << endl;
LARGE_INTEGER end = MilliSecondTimeStamp();
long long time = MilliSecondTimeCost(begin, end);
cout << endl << "execute cost " << time << "ms" << endl;
//int time=( ((liPerfNow.QuadPart - m_liPerfStart.QuadPart) * 1000)/m_liPerfFreq.QuadPart);
//char buffer[100];
//sprintf(buffer, "execute cost%d millisecond ", time);
//cout << buffer << endl;
return 0;
}
Windows 毫秒计时的更多相关文章
- STM32-RTC实时时钟-毫秒计时实现
OS:Windows 64 Development kit:MDK5.14 IDE:UV4 MCU:STM32F103C8T6 1.RTC时钟简介 STM32 的实时时钟(RTC)是一个独立的定时器, ...
- Windows 各种计时函数总结
本文对Windows平台下常用的计时函数进行总结,包括精度为秒.毫秒.微秒三种精度的 5种方法.分为在标准C/C++下的二种time()及clock(),标准C/C++所以使用的time()及cloc ...
- <转>Windows 各种计时函数总结
本文转自MoreWindows 特此标识感谢 http://blog.csdn.net/morewindows/article/details/6854764 本文对Windows平台下常用的计时函数 ...
- c++ windows下计时
多核时代不宜再用 x86 的 RDTSC 指令测试指令周期和时间 陈硕Blog.csdn.net/Solstice 自从 Intel Pentium 加入 RDTSC 指令以来,这条指令是 micro ...
- Windows 各种计时函数总结(QueryPerformanceCounter可以达到微秒)
本文对Windows平台下常用的计时函数进行总结,包括精度为秒.毫秒.微秒三种精度的5种方法.分为在标准C/C++下的二种time()及clock(),标准C/C++所以使用的time()及clock ...
- C#Stopwatch的简单计时zz
Stopwatch 类 命名空间:System.Diagnostics.Stopwatch 实例化:Stopwatch getTime=new Stopwatch(); 开始计时:getTime.St ...
- MoreWindows 微软认证专家博客目录(白话算法,C++ STL,windows编程)
为了方便大家查找和学习,现将本人博客中所有博客文章列出目录. (http://blog.csdn.net/morewindows) 一. 白话经典算法 目前有17篇,分为七大排序和经典面试题 ...
- Windows系统时间(FILETIME和SYSTEMTIME)
转载请标明出处,原文地址:http://blog.csdn.net/morewindows/article/details/8654298 欢迎关注微博:http://weibo.com/MoreWi ...
- C#Stopwatch的简单计时 [收藏]
Stopwatch 类 命名空间:System.Diagnostics.Stopwatch 实例化:Stopwatch getTime=new Stopwatch(); 开始计时:getTime.St ...
随机推荐
- js事件篇
javascript和html之间的交互式通过事件来实现的,事件就是文档或浏览器窗口中发生的一些特定的交互. 事件流:描述的是从页面中接收事件的顺序. 不同的是,IE和Netscape开发团队竟然提出 ...
- laravel验证器例子
直接贴测试代码 Route::get('/', function() { $name = "rico"; $validateData = array('name1' => $ ...
- android 文件上传,中文utf-8编码
要上传文件到后台的php服务器,服务器能收到中文,手机发送过去,却只能收到一堆转了UTF-8的编码(就是要decode后才是中文的编码).android这边上传文件通常是用stream方式上传的,用M ...
- clientHeight , scrollHeight , offsetHeight之间的区别及兼容方案
clientHeight , scrollHeight , offsetHeight相信每个人都用过,可是每次用都要查一下到底哪个是文档大小哪个是视口大小,还有头疼的兼容问题. 先来官方的了解一下这三 ...
- java代码----------计算器代码
总结: 很多不完善—— package com.rue; import java.awt.BorderLayout; import java.awt.FlowLayout; import java.a ...
- 小程序scroll-view组件使用时,子元素虽设置样式display:inline-flex;whit-space:nowrap
小程序scroll-view组件使用时,子元素虽设置样式display:inline-flex;whit-space:nowrap
- 多个else if语句
public class demo { public static void main(String[] args) { boolean examIsDone = true; int score = ...
- Whoops, looks like something went wrong
Whoops, looks like something went wrong. 这是由于访问laravel项目报错的,解决几种可能出现的错误. 1)打开:D:\java\wamp\www\subwa ...
- 短URL链接系统
定义: 短网址(Short URL),顾名思义就是在形式上比较短的网址.但不知道有多少人像我一样,由于面试问道才知道有这种系统而对短连接原理好奇,从而进行进一步的研究.在Web 2.0的今天,不得不说 ...
- window.location和window.open的区别
window.location = "http://www.baidu.com" 跳转后有后退功能 window.location.replace("http://www ...