当前位置: 首页 > news >正文

网站上的代码网页怎么做的抖音引流推广怎么做

网站上的代码网页怎么做的,抖音引流推广怎么做,网站配图尺寸,广州旅游网站建设设计一、简介 本文介绍了两种在C代码中统计耗时的方法&#xff0c;第一种使用<time.h>头文件中的clock()函数记录时间戳&#xff0c;统计程序耗时。第二种使用<chrono>头文件中的std::chrono::high_resolution_clock()::now()函数&#xff0c;后者可以方便地统计不同时…

一、简介

本文介绍了两种在C++代码中统计耗时的方法,第一种使用<time.h>头文件中的clock()函数记录时间戳,统计程序耗时。第二种使用<chrono>头文件中的std::chrono::high_resolution_clock()::now()函数,后者可以方便地统计不同时间单位下的程序耗时,例如秒(s)、毫秒(ms)、微秒(μs)或者纳秒(ns)。

二、代码示例

1. 使用<time.h>头文件中的clock()函数统计耗时

#include <iostream>
#include <time.h>
#include <math.h>
int main(int, char **)
{clock_t start;clock_t finish;start = clock(); // 开始计时/* do some thing */for (int i = 0; i < 10000; i++){float c = exp(2.0);}finish = clock(); // 结束计时// 打印程序耗时,单位:秒sstd::cout << (double)(finish - start) / CLOCKS_PER_SEC << std::endl;
}

2. 使用 <chrono>头文件中的std::chrono::high_resolution_clock::now()函数统计耗时

#include <iostream>
#include <math.h>
#include <chrono>int main(int, char **)
{std::chrono::high_resolution_clock::time_point start;std::chrono::high_resolution_clock::time_point finish;start = std::chrono::high_resolution_clock::now(); // 开始计时// do some thingfor (int i = 0; i < 10000; i++){float c = exp(2.0);}finish = std::chrono::high_resolution_clock::now(); // 结束计时// 打印程序耗时std::cout << "耗时为:" << std::chrono::duration_cast<std::chrono::seconds>(finish - start).count() << "s.\n";std::cout << "耗时为:" << std::chrono::duration_cast<std::chrono::milliseconds>(finish - start).count() << "ms.\n";std::cout << "耗时为:" << std::chrono::duration_cast<std::chrono::microseconds>(finish - start).count() << "us.\n";std::cout << "耗时为:" << std::chrono::duration_cast<std::chrono::nanoseconds>(finish - start).count() << "ns.\n";return 0;
}

三、参考

[1].C++函数耗时计算

http://www.mmbaike.com/news/81383.html

相关文章:

  • wordpress仿站方法网络营销的模式有哪些?
  • 做b2b网站赚钱sem网络营销
  • 开发jsp网站汕头网站设计
  • 重庆 机械有限公司 江北网站建设百度快照
  • 大邑网站建设互联网宣传推广
  • 门户网站个人可以做淘宝seo 优化软件
  • 黑别人网站怎么做自己的网页
  • asp网站怎么仿站岳阳seo公司
  • 多个域名指向同一个网站软件编程培训学校排名
  • asp网站建设实验设计宁波seo整站优化软件
  • 域名如何指向网站爱站小工具
  • 有没有做美食的视频网站网站的seo是什么意思
  • 专门做美妆的网站网站内容优化关键词布局
  • 有哪个网站可以查别人做没做过牢吗网络营销推广实训报告
  • 试用网建设网站百度竞价开户费用
  • 网站反链如何做上海职业技能培训机构一览表
  • 泰州专业网站制作公司网红推广一般怎么收费
  • 大庆市建设局网站刘东网络营销的具体形式种类
  • 衡阳网站建设mdawl人民日报今日头条新闻
  • 济宁专业做优化的网站关键词是什么
  • 超变攻速传奇一秒20刀网站seo网络优化
  • 简单网站建设哪家便宜店铺推广软文案例
  • 长春住房和城乡建设部官方网站百度点击率排名有效果吗
  • 网站怎么做用什么软件网站外链是什么意思
  • 免费网站建站软件浏览器网站大全
  • 建网站推广效果怎么样谷歌外链工具
  • 网络公司最好的是哪个seo怎么做优化
  • 完整的网站建设seo网站推广教程
  • 深圳做网站要多少新闻发布会新闻通稿
  • 可以直接做ppt的网站吗个人介绍网页制作